akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;

int N;

bool is_753(ll n) {
	string str = to_string(n);
	bool a[3] = {};
	rep(i, (int)str.size()) {
		if (str[i] == '7') {
			a[0] = 1;
		} else if (str[i] == '5') {
			a[1] = 1;
		} else if (str[i] == '3') {
			a[2] = 1;
		} else {
			return false;
		}
	}

	if (a[0]&&a[1]&&a[2]) {
		return true;
	}
	return false;
} 

int solve(ll k) {
	if (k > N) {
		return 0;
	}
	int cnt = 0;
	if (is_753(k)) {
		cnt++;
	}
	cnt+=solve(k*10 + 7);
	cnt+=solve(k*10 + 5);
	cnt+=solve(k*10 + 3);
	return cnt;
}

int main(){
	cin >> N;
	int cnt = solve(0);
	cout << cnt << endl;

	return 0;
}

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

int main(void){
   int a1,a2,a3,a4;
   cin >> a1;
   cin >> a2;
   cin >> a3;
   cin >> a4;
   int S=a1+a2+a3+a4;
   int b1,b2,b3,b4;
   cin >> b1;
   cin >> b2;
   cin >> b3;
   cin >> b4;
   int T=b1+b2+b3+b4;
   
   if(S < T){
      cout << T << endl;
    }
    else if(T < S) {
      cout << S << endl;
       }
    else{
        cout << T << endl;
    }
   }

   


Measured memory_bytes: 3092
#include <bits/stdc++.h>
 
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
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; }
 
int main()
{
  string S, T;
  cin >> S >> T;

 
  
  int M = int(T.size());
  int N = int(S.size());

  set<string> st;
  priority_queue<string> q; 
  
  for(int i=S.size()-1; i>M-2; i--)
    {
   
      if(S[i]==T[M-1] || S[i]=='?')
	{
        
        
	  for(int j=M-1; j>-1; j--)
	    {
        
	      if(S[i-(M-1-j)]==T[j] || S[i-(M-1-j)]=='?')
		{
		  
		}
	      else
		{
		  break;
		}
 
	      if(j==0)
		{
		  string res=S;
		  //for(int i=0; i<N; i++)
		  //res[i]=S[i];

		  // cout << res << endl;
		  
		  for(int k=0; k<N; k++)
		    {
		      
		      if(k==i-M+1)
			{
			  while(k-i+M-1<M)
			    {
			      res[k]=T[k-i+M-1];
			      k++;
			    }
			}
		      if(S[k]=='?')
			{
			  res[k]='a';
			}
		     
		    }
		  q.push(res);
		  if(q.size()>1)
		    q.pop();
		}
	    }
	}
    }

    
  if(!q.empty())
    cout << q.top() << endl;
  else
    cout << "UNRESTORABLE" << endl;
  
 
  return 0;
}
 
 
//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int judge(int a, int b){
	for(int i = 0;(a + i) < (b - i);i++){
		if(s[a + i] != s[b - i]){
			return 0;
		}
	}
	return 1;
}
int main(){
	cin >> s;
	int n = s.size();
	if((judge(0, n - 1) && judge(0, (n - 1) / 2 - 1)) && judge((n + 3) / 2 - 1, n - 1)){
		cout << "Yes";
	}else{
		cout << "No";
	}
	cout << endl;
}

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

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(int yy = 0; yy < YY; ++yy)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv)
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int N; cin >> N;
    string S; cin >> S;
    if(N%2){ cout << "No" << endl; return 0; }

    string S1, S2;

    for(int i = 0; i < N/2; ++i)
        S1 += S[i];
    for(int i = N/2; i < N; ++i)
        S2 += S[i];

    if(S1 == S2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main(){

    input!{
        p: usize,
        q: usize,
        r: usize,
    }

    println!("{}", std::cmp::min(std::cmp::min(p+q,q+r), r+p));

}

Measured memory_bytes: 4476
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                count += 1

print(count)


Measured memory_bytes: 3060
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)998244353;
//}}}


int w[200001];
int b[200001];

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  b[0] = 0;
  rep(i, 1, N + 1){
    b[i] = b[i - 1] + (S[i - 1] == '#');
  }
  w[N] = 0;
  rrep(i, N){
    w[i] = w[i + 1] + (S[i] == '.');
  }
  int ans = N;
  rep(i, N + 1){
    ans = min(ans, b[i] + w[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2180
#include "bits/stdc++.h"
using namespace std;

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

int main() {
        int n;
        scanf("%d", &n);
        vector<pair<int, int>> x(n);
        for (int i = 0; i < n; i ++) { 
                scanf("%d", &x[i].first);
                x[i].first --;
                x[i].second = i + 1;
        }
        sort(all(x));
        int sp = 0;
        vector<int> ans(n * n, -1);
        for (int i = 0; i < n; i ++) {
                ans[x[i].first] = x[i].second;
                int add = x[i].second - 1;
                while (add --) {
                        if (ans[sp] != -1) add ++;
                        else ans[sp] = x[i].second;
                        sp ++;
                        if (sp > x[i].first) return !puts("No");
                }
        }
        for (int i = 0; i < n; i ++) {
                if (ans[sp] == -1 && sp < x[i].first) return !puts("No");
                int add = n - x[i].second;
                cerr << "sp = " << sp << endl;
                cerr << "add = " << add << endl;
                while (add --) {
                        if (ans[sp] != -1) add ++;
                        else ans[sp] = x[i].second;
                        sp ++;
                }
        }
        puts("Yes");
        for (int i = 0; i < n * n; i ++) cout << ans[i] << (i == n * n - 1 ? '\n' : ' ');
        return 0;   
}



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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 16 + 5, Maxs = (1 << 16) + 100;

int N, M, A[Maxn];
int Dp[Maxn][Maxs];

namespace MATH
{
	const int Mod = 1e9 + 7;
	int fac[Maxs], ifac[Maxs], pw[Maxn];

	inline void Add (int &a, int b) { if ((a += b) >= Mod) a -= Mod; }

	inline int Pow (int a, int b)
	{
		int ans = 1;
		for (int i = b; i; i >>= 1, a = (LL) a * a % Mod) if (i & 1) ans = (LL) ans * a % Mod;
		return ans;
	}

	inline void init (int n = Maxs - 10)
	{
		fac[0] = 1;
		for (int i = 1; i <= n; ++i) fac[i] = (LL) fac[i - 1] * i % Mod;
		ifac[n] = Pow (fac[n], Mod - 2);
		for (int i = n - 1; i >= 0; --i) ifac[i] = (LL) ifac[i + 1] * (i + 1) % Mod;

		pw[0] = 1;
		for (int i = 1; i <= Maxn - 3; ++i) pw[i] = pw[i - 1] << 1;
	}

	inline int C (int n, int m) { if (n < m) return 0; return (LL) fac[n] * ifac[m] % Mod * ifac[n - m] % Mod; }
}

using namespace MATH;

inline void Solve ()
{
	int ALL = (1 << N) - 1;
	Dp[0][0] = 1;
	for (int i = 0; i < M; ++i)
		for (int S = 0; S <= ALL; ++S)
		{
			if (!Dp[i][S]) continue;
			Add (Dp[i + 1][S], Dp[i][S]);
			for (int j = 0; j < N; ++j)
			{
				if (S & pw[j]) continue;
				int coef = (LL) C (pw[N] - S - A[i + 1], pw[j] - 1) * fac[pw[j]] % Mod;
				Add (Dp[i + 1][S | pw[j]], (LL) Dp[i][S] * coef % Mod);
			}
		}

	int ans = 0;
	for (int i = 0; i <= ALL; ++i)
	{
		int sum = (LL) Dp[M][i] * fac[ALL - i] % Mod;
		if (__builtin_popcount (i) & 1) Add (ans, Mod - sum);
		else Add (ans, sum);
	}

	cout << (LL) ans * pw[N] % Mod << endl;
}

inline void Input ()
{
	N = read<int>(), M = read<int>();
	for (int i = 1; i <= M; ++i) A[i] = read<int>();
	sort (A + 1, A + M + 1, greater<int>());
}

int main()
{

#ifdef hk_cnyali
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	MATH :: init ();
	Input ();
	Solve ();

	return 0;
}


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

int main(void) {
    int N, M, T;
    cin >> N >> M >> T;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int sumTime = 0;
    if (A[0] - M > 0) sumTime += A[0] - M;

    for (int i = 1; i < A.size(); i++) {
        if (A[i] - A[i - 1] > 2 * M) sumTime += A[i] - A[i - 1] - 2 * M;
    }
    if (T - A[A.size() - 1] > M) sumTime += T - A[A.size() - 1] - M;
    cout << sumTime << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int dp[100000],i,ans;

signed main(){
    FASTER;
    int a,b;cin>>a>>b;

    for(i=0;;i++){
        if(i==0){
            dp[i]=1;
        }else{
            dp[i]=dp[i-1]-1+a;
        }
        if(dp[i]>=b){
            ans=i;
            break;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;

#define MAX_N 100000000
#define INF 1000000000

int main(){
  long long n,k;
  cin >> n >> k;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int digit = 41;
  long long f = 0;
  long long x = 0;
  int count_0 = 0;
  int count_1 = 0;


  for(int i=digit-1;i>=0;i--){
    count_0 = 0;
    count_1 = 0;
    for(int j=0;j<n;j++){
      if(((long long) 1 << i) & a[j]){
        count_0 += 1;

      }
      else{
        count_1 += 1;
      }
    }

    if(x + ((long long) 1 << i) <= k && count_1 > count_0){
      f += ((long long) 1 << i)*count_1;
      x += ((long long) 1 << i);
    }
    else{
      f += ((long long) 1 << i)*count_0;
    }

  }

  cout << f << endl;
  return 0;
}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

double getD(double T, double x) {
    return T - x * 0.006;
}

int main() {

    int N;
    cin >> N;

    double T, A;
    cin >> T >> A;

    vector<long long> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    int index = 0;
    for (int i = 0; i < N; i++) if (abs(getD(T, H[index]) - A) > abs(getD(T, H[i]) - A)) index = i;
    cout << index + 1 << endl;

    return 0;
}











































































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

long long n,x,a[2050];
long long mn[2050][2050];

main()
{
	scanf("%lld %lld",&n,&x);
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		mn[0][i]=a[i];
		ans+=mn[0][i];
	}
	for(int i=1;i<n;i++)
	{
		long long sum=0;
		for(int j=0;j<n;j++)
		{
			int chk=j-i;
			if(chk<0)
				chk=n+chk;
			mn[i][j]=min(mn[i-1][j],a[chk]);
			sum+=mn[i][j];
		}
		ans=min(ans,sum+i*x);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 33152
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = 0;
    ll t = N / (A + B);
    ans += t * A;

    ll o = N % (A + B);
    if (o >= A) {
        ans += A;
    } else {
        ans += o;
    }

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


Measured memory_bytes: 256
#abc112c

n=int(raw_input())
l=[]
for i in xrange(n):
 x,y,h=map(int,raw_input().split())
 l.append([x,y,h])
for cx in xrange(101):
 for cy in xrange(101):
  for k in xrange(n):
   if l[k][2]>0:
    h=abs(l[k][0]-cx)+abs(l[k][1]-cy)+l[k][2]
    break
  flag=False
  for k in xrange(n):
   if l[k][2]!=max(h-abs(l[k][0]-cx)-abs(l[k][1]-cy),0):
    flag=True
    break
  if flag==False:
   print cx,cy,h


Measured memory_bytes: 2692
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1> void rsortA_L(int N, T1 a[], void *mem = wmem){
  sortA_L(N, a, mem);
  reverse(a, a+N);
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int M;
int V;
int P;
int A[100000];
int main(){
  wmem = memarr;
  int res;
  long long val;
  long long nd;
  rd(N);
  rd(M);
  rd(V);
  rd(P);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  rsortA_L(N,A);
  int cTE1_r3A;
  int RZTsC2BF;
  int FmcKpFmN;
  cTE1_r3A = P;
  RZTsC2BF = N;
  while(cTE1_r3A < RZTsC2BF){
    if((cTE1_r3A + RZTsC2BF)%2==0){
      FmcKpFmN = (cTE1_r3A + RZTsC2BF) / 2;
    }
    else{
      FmcKpFmN = (cTE1_r3A + RZTsC2BF + 1) / 2;
    }
    val = A[FmcKpFmN-1] + M;
    if(val < A[P-1]){
      nd = 1;
    }
    else{
      int i;
      nd =min_L(V, P-1 + N-FmcKpFmN+1);
      nd = (long long) (V - nd) * M;
      for(i=(P-1);i<(FmcKpFmN-1);i++){
        if(A[i] < val){
          nd -= val - A[i];
        }
      }
    }
    if(nd <= 0){
      cTE1_r3A = FmcKpFmN;
    }
    else{
      RZTsC2BF = FmcKpFmN - 1;
    }
  }
  res =RZTsC2BF;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191227-1

// --- original code ---
// int N, M, V, P, A[1d5];
// {
//   int res;
//   ll val, nd;
//   rd(N,M,V,P,A(N));
//   rsortA(N,A);
//   res = bsearch_max[int,x,P,N][
//     val = A[x-1] + M;
//     if(val < A[P-1]){
//       nd = 1;
//     } else {
//       nd = min(V, P-1 + N-x+1);
//       nd = (ll) (V - nd) * M;
//       rep(i,P-1,x-1) if(A[i] < val) nd -= val - A[i];
//     }
//   ](nd <= 0);
//   wt(res);
// }


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

int main() {
  int n; cin>>n;
  vector<pair<pair<string,int>,int>> v(n);
 
  rep(i,n){
    cin>>v.at(i).first.first>>v.at(i).first.second;
    v.at(i).second=i+1;
    v.at(i).first.second=100-v.at(i).first.second;
  }
  
  sort(v.begin(),v.end());
  rep(i,n){
    cout<</*v.at(i).first.first
      <<" "<<100-v.at(i).first.second
      <<" "<<*/v.at(i).second<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, K;
    cin >> N >> K;
    if(K == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << N - K << endl;
    return 0;
}

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

int main()
{
int a,b;
cin>>a>>b;
if(b==1){cout<<0;
return 0;}
int c=1;
int k=0;
int temp=b;
while(b>0)
{ k++;
    c=c+a-1;
    b=temp-c;
}
  cout<<k;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2 == 0) printf("#");
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2604
#include<iostream>
using namespace std;
 
bool prime(int p){
for(int i=2;i*i<=p;i++)
if(!(p%i))return false;
return true;
}
 
int main(){
int n,p,ans=0;
cin >> n;
for(int i=0;i<n;i++){
cin >> p;
if(prime(p))ans++;
}
cout << ans << endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() { int n;
  cin >> n;
  if (n == 1) cout << "Hello World" << endl;
  else{
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[100010];
int main(){
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 1000000007;
	for (int j = k - 1; j < n; j++) {
		int m = a[j] - a[j - k + 1];
		int s = min(abs(0 - a[j]), abs(0 - a[j - k + 1]));
		if (ans > m + s) {
			ans = m + s;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []

using namespace std;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

template<typename T>
void p(T elem) {cout << elem << endl;}
template<typename T>
void ps(vector<T>& arr) { for(T e: arr) p(e); }

int main(void) {
    int num;
    cin >> num;
    vector<int> arr(num);
    cins(arr);

    set<int> se;
    for(int elem: arr) {
        se.insert(elem);
    }
    cout << se.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include<math.h>
#include <vector>
#include<bitset>
#include<map>
using namespace std;

int main() {
	int n, count = 0; cin >> n;
	int a[n]; for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		int minj = i;
		bool change = 0;
		for (int j = i; j < n; j++) {
			if (a[j] < a[minj]) {
				minj = j;
				change = 1;
			}
		}
		swap(a[i], a[minj]);
		if (change)count++;
	}
	for (int i = 0; i < n-1; i++)cout << a[i] << ' ';
	cout <<a[n-1]<< endl << count << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll K;
    while(cin>>K){
        ll n = 0;
        bool f = 0;
        fore(i,1,1e7+10){
            n = (n*10 + 7)%K;
            if(n==0){
                cout<<i<<"\n";
                f = 1;
                break;
            }
        }
        if(!f){
            cout<<-1<<"\n";
        }
    }
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    LL ans = 0;
    queue<string> q;
    q.push("3");
    q.push("5");
    q.push("7");
    while(!q.empty()){
        auto s = q.front();q.pop();
        set<char> st;
        for(auto c : s) st.insert(c);
        if(stoi(s) <= n && st.size() == 3) ans++;
        if(s.size() == 9) continue;
        q.push("3"+s);
        q.push("5"+s);
        q.push("7"+s);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
N,M=map(int,input().split())
H=list(map(int,input().split()))

ans_list=[1]*N

for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]<H[b-1]:
        ans_list[a-1]=0
    if H[a-1]>H[b-1]:
        ans_list[b-1]=0
    if H[a-1]==H[b-1]:
        ans_list[a-1]=0
        ans_list[b-1]=0
print(sum(ans_list))

Measured memory_bytes: 20036
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 x = scan<u32>();
  for (u32 c = 0; c <= x; c += 1) {
    if (c * 100 > x) {
      break;
    }
    const u32 t = x - c * 100;
    if (t <= 5 * c) {
      std::cout << 1 << std::endl;
      return;
    }
  }
  std::cout << 0 << std::endl;
  return;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
n, m, x = list(map(int, input().split()))
a = []
c = []
for _ in range(n):
    list_ = list(map(int, input().split()))
    c.append(list_[0])
    list_.pop(0)
    a.append(list_)
res = -1
bit = []
for i in range(2 ** n):
    tmp = [False] * n
    for j in range(n):
        if i >> j & 1:
            tmp[j] = True
    bit.append(tmp)
bit.pop(0)
cost = 10 ** 10
f = False
for i in range(2 ** n - 1):
    tmp_cost = 0
    tmp_f = True
    list_ = [0] * m
    for j in range(n):
        if bit[i][j]:
            tmp_cost += c[j]
            for k in range(m):
                list_[k] += a[j][k]
    for k in range(m):
        if list_[k] >= x:
            pass
        else:
            tmp_f = False
    if tmp_f:
        cost = min(tmp_cost, cost)
        f = True
if f:
    res = cost
print(res)


Measured memory_bytes: 9664
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int min = int.MaxValue;
        for(int i = 0; i < s.Length - 2; i++)
        {
            int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
            if(Math.Abs(753 - num) < min)
            {
                min = Math.Abs(753 - num);
            }
        }
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  int N,K;
  cin>>N;
  cin>>K;
  vector<int> h(N);
  vector<int> c(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
    c[i]=-1;
  }
  c[0]=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i+j<N){
        if(c[i+j] == -1){
          c[i+j] = c[i] + abs(h[i+j]-h[i]);
        }
        else if(c[i+j] > c[i] + abs(h[i+j]-h[i])){
          c[i+j] = c[i] + abs(h[i+j]-h[i]);
        }
      }
    }
  }
  /*
  for(int i=0;i<N;i++){
    cout << c[i] << " ";
  }
  cout << endl;
  */
  cout << c[N-1] << endl;

  return 0;
}


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

typedef long long ll;
using namespace std;

typedef long double ldouble;

const ll MAXN = 1000001;

long long a, b, c;

int main()
{
    cin >> a >> b >> c;
    int mx = max(a, max(b, c));
    int mn = min(a, min(b, c));
    int mnx = a + b + c - mx - mn;
    cout << (mnx * mn) / 2;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int k = sc.nextInt();
			int m = sc.nextInt();
			if(n==0 && k==0 && m==0) break;
			
			m--;
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i=1;i<=n;i++) list.add(i);
			for(int i=n-1;i>0;i--){	
				list.remove(m);
				m+=(k-1);
				while(m>=i) m-=i;
			}
			System.out.println(list.get(0));
		}	
	}	
}

Measured memory_bytes: 37856
#include <stdio.h>
int main(){
  
  int x[10];
  int r,D,s,i;
  
  scanf("%d %d %d", &r, &D, &s);
  
  x[0] = s;
  for(i = 0; i < 10; i++){
    x[i + 1] = r * x[i] - D;
    printf("%d\n", x[i + 1]);
  }
  
  return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    if(N%2==0){
        cout<<0.5<<endl;
    }else{
       double ans;
       ans=((double)(N+1)/2)/N;
       cout<<ans<<endl; 
    }    
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int A, B;
    cin >> A >> B;

    if (B > A)
        swap(A, B);

    if ((A - B) % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;

        return 0;
    }

    cout << B + (A - B) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const int N=1e3+5;
const ll inf=1e18;
ll n,a[N];
vector<ll> p[2];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	ii mx=ii(-inf,-inf);	
	for(int i=0;i<2;i++)
	{
		ll tot=0;
		ii mx2=ii(-inf,-inf);
		for(int j=0;j<n;j++)
		{
			if(j%2!=i)	continue;
			if(a[j]>0)
			{
				p[i].push_back(j);
				tot+=a[j];
			}
			mx2=max(mx2,ii(a[j],j));	
		}
		if(p[i].size()==0)
		{
			tot=mx2.first;
			p[i].push_back(mx2.second);
		}
		mx=max(mx,ii(tot,i));
	} 
	vector<ll> arr=p[mx.second],op;
	int sz=arr.size(); 
	for(int i=n-1;i>arr[sz-1];i--)
		op.push_back(i);
	for(int i=0;i<arr[0];i++)
		op.push_back(0); 
	for(int i=0;i<arr.size()-1;i++)
	{
		int d=arr[i+1]-arr[i];
		for(int j=d/2;j>=1;j--)
			op.push_back(j);
	}
	cout<<mx.first<<'\n';
	cout<<op.size()<<'\n';
	for(int i=0;i<op.size();i++)
		cout<<op[i]+1<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

const int md = 1e9+7;

void add(int &a, int b)
{
	a += b;
	if(a>= md) a -= md;
}

int mul(int a, int b)
{
	return (1LL*a*b)%md;
}

const int maxn = 1e5+5;
char s[maxn];

int pong(int a, int b)
{
	if(b == 0) return 1;
	int x = pong(a, b/2);
	int y = mul(x, x);
	if(b%2) y = mul(y, a);
	return y;
}
int calc(int fix, int free)
{
	int res = mul(fix, pong(3, free));
	add(res, mul(free, pong(3, free-1)));
	return res;
}
int a[maxn];
int b[maxn];
int c[maxn];
int q[maxn];
int main()
{
	scanf("%s", s+1);
	int n = strlen(s+1);
	for(int i = 1; i<= n; i++)
	{
		a[i] = a[i-1];
		b[i] = b[i-1];
		c[i] = c[i-1];
		q[i] = q[i-1];
		if(s[i] == 'A') a[i]++;
		else if(s[i] == 'B') b[i]++;
		else if(s[i] == 'C') c[i]++;
		else q[i]++;
	}
	int res = 0;
	for(int i = 1; i<= n; i++)
	{
		int fixL, freeL, fixR, freeR;
		fixL = a[i-1];
		freeL = q[i-1];
		fixR = c[n]-c[i];
		freeR = q[n]-q[i];
		//printf("%d %d %d %d\n", fixL, freeL, fixR, freeR);
		if(s[i] == 'B' || s[i] == '?')
		{
			add(res, mul(calc(fixL, freeL), calc(fixR, freeR)));
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    string s;cin>>s;
    For(i,2,n){
         if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C') ans++;
    }
    cout<<ans<<endl;
}
int main(){
     Main();
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  ll K;
  I(N);
  I(K);
  vl A(N);
  REP(i, N) {
    I(A[i]);
  }
  sort(ALL(A));
  REP(i, K) {
    ret += A[i];
  }

  P(ret);

}


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

signed main() {
    int n;
    cin >> n;
    vector <int> x(n), y(n), h(n);

    rep(i, n)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    rep(i, 101) rep(j, 101)
    {
        bool ok = true;
        int ans_h = -1;
        rep(k, n)
        {
            if(h[k] != 0)
            {
                ans_h = h[k] + abs(i - x[k]) + abs(j - y[k]);
                break;
            }
        }

        rep(k, n)
        {
            if(max(ans_h - abs(i - x[k]) - abs(j - y[k]), 0LL) != h[k])
            {
                ok = false;
                break;
            }
        }

        if(ok)
        {
            cout << i << " " << j << " " << ans_h << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n, W;
    cin >> n >> W;
    
    int w[n+1], v[n+1];
    forn(i, 1, n+1) {
        cin >> w[i] >> v[i];
    }
    
    ll dp[W+1] = {};
    forn(i, 1, n+1) {
        for (int j = W; j >= w[i]; --j) {
            ll a = dp[j];
            ll b = dp[ j-w[i] ] + v[i];
            dp[j] = max(a, b);
        }
    }
    
    cout << dp[W] << endl;
}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
int h,w;
char s[15][15];
bool used[15][15];
int main()
{
	cin>>h>>w;
	for (int i=1;i<=h;i++)
	{
		scanf("%s",s[i]+1);
	}
	int x=1,y=1;
	used[1][1]=true;
	while (x!=h || y!=w)
	{
		if (s[x+1][y]=='#')
		{
			x++;
		}
		else if (s[x][y+1]=='#')
		{
			y++;
		}
		else
		{
			break;
		}
		used[x][y]=true;
	}
	if (x!=h || y!=w)
	{
		puts("Impossible");
		return 0;
	}
	for (int i=1;i<=h;i++)
	{
		for (int j=1;j<=w;j++)
		{
			if (s[i][j]=='#' && !used[i][j])
			{
				puts("Impossible");
				return 0;
			}
		}
	}
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
string s;

int32_t main(){_
      
   cin >> n;
   int sum = 0;

   for (int i = 1; i <= n; ++i)
   {
      if (i % 3 == 0 or i % 5 == 0){
         
      }
      else{
         sum += i;
      }
   }

   cout<<sum;

   return 0;
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
#ABC74 C

a,b,c,d,e,f = map(int,input().split())

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
water = [100*a*A + 100*b*B for B in range(t+1) for A in range(s+1) if 100*a*A + 100*b*B != 0]
suger = [c*C + d*D for D in range(v+1) for C in range(u+1)]
ans1 = 0
ans2 = 0
water = list(set(water))
suger = list(set(suger))
for W in water:
    for S in suger:
        if W + S <= f:
            if W*e >= 100*S:
                if concentration < S/(W+S):
                    concentration = S/(W+S)
                    ans1 = W+S
                    ans2 = S
if ans1 == 0:
    ans1 = 100*a
print(ans1,ans2)


Measured memory_bytes: 22488
# 最初は0から始まる
# その次は、今の数+1以下である必要がある。
# 今の数+2以上が現れたらNG
# 通常は（0以外のときに）ans += 1
# 同じ数以下のとき、たとえば5 -> 3となっているときは、
# それまでに3を作れているはずなので、3を足す

N = int(input())
cur = 0
ans = 0
for i in range(N):
  a = int(input())
  if i == 0 and a != 0:
    print(-1)
    exit(0)
  elif a == 0:
    ans += 0
  elif a == cur + 1:
    ans += 1
  elif a <= cur:
    ans += a
  else:
    print(-1)
    exit(0)
  cur = a
print(ans)

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

void solve(long long N)
{
    for (long long i = 1; i <= N; i++)
    {
        long long cnt = 0;
        for (long long j = 1; j <= N; j++)
        {
            if (j * j > N)
                break;

            for (long long k = 1; k <= N; k++)
            {
                if (j * j + k * k + j * k > N)
                    break;

                for (long long l = 1; l <= N; l++)
                {
                    long long f = j * j + k * k + l * l + j * k + j * l + k * l;
                    if (f == i)
                        cnt++;
                    else if (f > i)
                        break;
                }
            }
        }
        cout << cnt << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3652
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e12;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

const ll mod = 1e9+7;

ll modpow(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N; cin >> N;
    vd p(N, 0.0); REP(i, N) cin >> p[i];
    vvd dp(N+1, vd(N+1, 0.0)); dp[0][0] = 1.0;
    REP(i, N) REP(j, N+1){
        dp[i+1][j] = p[i] * dp[i][j-1] + (1.0 - p[i]) * dp[i][j];
    }
    double ans = 0.0;
    FOR(i, (N+1)/2, N+1){
        ans += dp[N][i];
    }
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 70784
#include<stdio.h>

int main(void){
    char str[1200] = "";
    const int offset = 'a'-'A';
    fgets(str, 1200, stdin);
    for(int i=0; str[i] != '\0'; i++){
        if('A'<=str[i] && str[i]<='Z'){
            str[i] += offset;
        }else if('a'<=str[i] && str[i]<='z'){
            str[i] -= offset;
        }
    }
    printf("%s", str);
    
}


Measured memory_bytes: 2044