akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

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

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

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

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

void solve(long long K, long long X) {
  int val = X-(K-1);
  while(1){
    cout<<val;
    val++;
    if(val>X+(K-1)){
      cout<<endl;
      return;
    }
    else cout<<" ";
  }
}

int main() {
  long long K;
  scanf("%lld", &K);
  long long X;
  scanf("%lld", &X);
  solve(K, X);
  return 0;
}


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

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, flag = 0;
    string s;
    cin >> n >> s;
    
    if (n%2 == 1) {
        cout << "No";
        return 0;
    }
    else {
        for (ll i = 0; i < n/2; i++) {
            if (s[i] != s[i+(n/2)]) {
                flag = 1;
                break;
            }
        }
    }
    if (flag == 1) cout << "No";
    else cout << "Yes";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	string ball[10] = {"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "},i;
	int f = 0;
	while(cin >> i,!cin.eof()){
		f&&cout<<endl;
		f?:f=1;
		while(i.size() < 5)i = '0' + i;
		for(int k=0;k<8;k++){
			for(int l=0;l<5;l++)cout << ball[i[l]-'0'][k];
			cout << endl;
		}
	}
}

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

int main() {
  while(1) {
    int n, k;
    cin >> n >> k;
    if(n == 0 && k == 0) break;
    int shima[n][n];
    fill(&shima[0][0], &shima[n-1][n-1]+1, 0);
    for(int t = 0; t < k; t++) {
      int mode;
      cin >> mode;
      if(mode == 0) {
	int a, b;
	cin >> a >> b;
	a--;
	b--;
	bool visited[n];
	fill(&visited[0], &visited[n-1]+1, false);
	int cost[n];
	fill(&cost[0], &cost[n-1]+1, 9999999);
	cost[a] = 0;
	while(1) {
	  int min = 9999999;
	  int p;
	  for(int i = 0; i < n; i++) {
	    if(!visited[i] && cost[i] < min) {
	      min = cost[i];
	      p = i;
	    }
	  }
	  if(min == 9999999) break;

	  visited[p] = true;
	  for(int i = 0; i < n; i++) {
	    if(visited[i]) continue;
	    if(shima[p][i] != 0) {
	      int newValue = cost[p] + shima[p][i];
	      if(newValue < cost[i]) cost[i] = newValue;
	    }
	  }
	}
	if(cost[b] == 9999999) cout << -1 << endl;
	else                   cout << cost[b] << endl;

      } else if(mode == 1) {
	int c, d, e;
	cin >> c >> d >> e;
	c--;
	d--;
	if(shima[c][d] == 0 || shima[c][d] > e) {
	  shima[c][d] = shima[d][c] = e;
	}
      }
    }
  }
  return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

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

int a, b, c, d, e, n, m, k;
string s, t, r;
char c1, c2, c3;

int A[200005];
int B[200005];
int C[200005];

int main() {
	cin >>n;
  	while (n--) {
      cin >>s;
      if (s == "AC") a++;
      if (s == "WA") b++;
      if (s == "TLE") c++;
      if (s == "RE") d++;
    }
  	cout <<"AC x "<<a<<endl;
  cout <<"WA x "<<b<<endl;
  cout <<"TLE x "<<c<<endl;
  cout <<"RE x "<<d<<endl;
	return 0;
}

Measured memory_bytes: 3636
function prime(max){
   var arr=[];
   for(var i=0;i<=max;i++)arr[i]=i;
   arr[0]=false;
   arr[1]=false;
   var sqrt=Math.floor(Math.sqrt(max));
   for(var i=2;i<=sqrt;i++){
      if(arr[i]==false)continue;
         for(var j=i+i;j<=max;j+=i){
            arr[j]=false;
         }
   }
   var obj={};
   for(var i=0;i<=max;i++){
      if(arr[i]!==false)obj[arr[i]]=true;
   }
   return obj;
}
var p=prime(1000000);
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var nx=Arr.shift().split(" ").map(Number);
   var n=nx[0];
   var x=nx[1];
   if(n==0 && x==0)break;
   var dp=[];
   for(var i=0;i<=1000000;i++)dp[i]=false;
   var arr=[];
   for(var i=0;i<n;i++){
      var v=Arr.shift()-0;
      arr.push(v);
      dp[v]=true;
   }
   dp[0]=true;
   for(var i=0;i<=1000000;i++){
      for(var j=0;j<arr.length;j++){
         if(i+arr[j]>1000000)continue;
         if(dp[i])dp[i+arr[j]]=true;
      }
   }
   for(var i=x;i>0;i--){
      if(dp[i] && p.hasOwnProperty(i))break;
   }
   console.log((i===0)?"NA":i);
}

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

int main(){
    int n;
    int w[150];
    int s1=0,s2=0;
    int min = 100000;

    cin >> n;
    for(int i = 0;i < n; i++){
        scanf("%d",&w[i]);
    }
    for(int t = 1;t < n;t++){
        for(int j = 0;j < n;j++){
            if(j < t){ s1 += w[j]; }else{ s2 += w[j]; }
        }
        if(s1 <= s2){
            if(s2 - s1 < min){
                min = s2 - s1;
            }
        }else if(s2 <= s1){
            if(s1 - s2< min){
                min = s1 - s2;
            }
        }
        s1 = 0;
        s2 = 0;
    }
    
    cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#define nl "\n"
using namespace std;
#define f(i, a, b) for(ll i = a; i<b;i++)
#define ll long long
int main()
{

    ll a, b, c, k;
    //cin>>a>>b>>c>>k;
    scanf("%lld%lld%lld%lld", &a, &b,&c,&k);
    ll sum = 0;

    if(a>=k)
    {
        sum+=k;
           // printf("%lld", k);

        cout<<sum<<nl;
        return 0;
    }
    else
    {
        sum += a;
        k-=a;
        if(b>=k)
        {
            sum += 0;
             //   printf("%lld", k);

            cout<<sum<<nl;
            return 0;
        }
        else{
            sum += (b*0);
            k-=b;
            if(c>=k)
            {
                sum-=k;
               //     printf("%lld", k);

                cout<<sum<<nl;
                return 0;
            }
            else
            {
                sum -= c;
                k-=c;
            }
        }
    }

   // cout<<k<<nl;
 //   printf("%lld", k);
    cout<<sum<<nl;


    return 0;
}
/*
 if(k-a>=0)
    {
        sum+=a;
        k -= a;
    }
    else{
        printf("%lld\n", sum);
//        cout<<k+sum<<nl;
        return 0;
    }
    if(k-b>=0)
    {
        k-=b;
    }
    else
    {
        cout<<sum<<nl;
        return 0;
    }
    if(k-c>=0)
    {
        sum -= c;
        k-=c;
    }
    else{
        cout<<sum-k<<nl;
    }

    */


Measured memory_bytes: 3764
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int dp[4][4][50][50][1<<10];
void decode(int u, int a[4][4])
{
	int b=1;
	for(int i=0;i<4;i++){
		for(int j=0;i+j<4;j++){
			a[i][j]=(u&b)?1:0;
			b<<=1;
		}
	}
}
int encode(int a[4][4]){
	int ret=0;
	int b=1;
	for(int i=0;i<4;i++){
		for(int j=0;i+j<4;j++){
			if(a[i][j]){
				ret|=b;
			}
			b<<=1;
		}
	}
	return ret;
}
void down(int a[4][4]){
	for(int i=3;i>=0;i--){
		for(int j=0;i+j<4;j++){
			if(0<=i-1){
				a[i][j]=a[i-1][j];
			}
			else
			{
				a[i][j]=0;
			}
		}
	}
}
void right(int a[4][4]){
	for(int i=0;i<4;i++){
		for(int j=3-i;j>=0;j--){
			if(0<=j-1){
				a[i][j]=a[i][j-1];
			}
			else
			{
				a[i][j]=0;
			}
		}
	}
}
int H,W,K;
char in[50][51];
int main() {
	scanf("%d%d%d",&H,&W,&K);
	for(int i=0;i<H;i++){
		scanf("%s",in[i]);
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0][0][0][0]=0;
	int ret=0;
	for(int i=0;i<=K;i++){
		for(int j=0;i+j<=K;j++){
			for(int x=0;x<H;x++){
				for(int y=0;y<W;y++){
					int dx=1;
					int dy=0;
					for(int k=0;k<4;k++,swap(dx,dy),dx=-dx){
						if(x+dx<0||H<=x+dx||y+dy<0||W<=y+dy||in[x+dx][y+dy]=='#'){
							continue;
						}
						if(dx<0||dy<0){
							if(i-dx>K||j-dy>K){
								continue;
							}
						}
						for(int u=0;u<1<<10;u++){
							if(dp[i][j][x][y][u]==-1){
								continue;
							}
							//cout << i << ", " << j << ", " << x << ", " << y << ", " << u << ": " << dp[i][j][x][y][u] << ", " << in[x][y] << endl;
							int a[4][4]={};
							decode(u,a);
							int v=dp[i][j][x][y][u];
							if(a[i][j]==0&&in[x][y]!='.'){
								v+=in[x][y]-'0';
							}
							a[i][j]=1;
							int ii=i;
							int jj=j;
							if(dx>0){
								down(a);
							}
							else if(dy>0){
								right(a);
							}
							else if(dx<0){
								ii++;
							}
							else if(dy<0){
								jj++;
							}
							int b=encode(a);
							dp[ii][jj][x+dx][y+dy][b]=max(dp[ii][jj][x+dx][y+dy][b],v);
						}
					}
				}
			}
			for(int u=0;u<1<<10;u++){
				ret=max(ret,dp[i][j][H-1][W-1][u]);
			}
		}
	}
	printf("%d\n",ret);
}

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

using namespace std;
int main(void){
    // Your code here!
    int r, g, b;
    cin >> r >> g >> b;
    
    int all = r * 100 + g * 10 + b;
    
    if ( all % 4 == 0 ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3544
S = list(str(input()))

status = 0
det = 0

for i in range(len(S)):
    if status == 0 and S[i] != "h":
        det = -1
        break
    elif status == 1 and S[i] != "i":
        det = -1
        break
    status += 1
    status %= 2

if det == 0 and status == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, ans=1;
    cin >> x;
    for(int i=2; i<100; i++){
        for(int j=2; j<10; j++){
            if(pow(i, j)<=x){
                ans = max(ans, int(pow(i, j)));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i*4<=n;i++)
    for(int j=0;j*7<=n;j++)
      if(i*4+j*7==n){
        cout<<"Yes"<<endl;
        return 0;
      }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

//素数かどうか判定　素数 => true
bool is_prime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}

//エラトステネスの篩
vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n + 1, 0);

  for (int i = 2; i <= n; i++) primes[i] = i;

  for (int i = 2; i * i <= n; i++) {
    if (0 == primes[i]) continue;  //  0ならば素数ではない
    for (int j = i + i; j <= n; j += i) primes[j] = 0;  //  iの倍数を0にする
  }

  // primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());

  return primes;
}

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

  int x, res = 0;
  while (N--) {
    cin >> x;
    res += is_prime(x);
  }
  cout << res << endl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<char> t(n);
  for(int i=0;i<n;i++){
    t.at(i) = s.at(n-1-i);
  }
  string k;
  int count = 0;
  for(int i=0;i<n;i++){
    if(n-1-i <=3){
      count++;
      break;
    }
    
    if(t.at(i) == 'm'){
      k += "maerd";
      i += 4;
      if(i >= n){
        count++;
        break;
      }
    }
    else if(t.at(i) == 'e'){
      k += "esare";
      i += 4;
      if(i >= n){
        count++;
        break;
      }
    }
    else if(t.at(i) == 'r' && t.at(i+2) == 'm'){
      k += "remaerd";
      i += 6;
      if(i >= n){
        count++;
        break;
      }
    }
    else if(t.at(i) == 'r' && t.at(i+2) == 's'){
      k += "resare";
      i += 5;
      if(i >= n){
        count++;
        break;
      }
    }
    else {
      count++;
      break;
    }
  }
  if(count >0){
    cout << "NO" << endl;
  }
  else {
  vector<char> r(n);
  for(int i=0;i<n;i++){
    r.at(i) = k.at(n-1-i);
    if(r.at(i) != s.at(i)){
      count++;
      break;
    }
  }
  if(count == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }    
  }
      
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int a[510][510];
inline void solve(int l,int r,int dep){
	if (l==r) return;
	if (r-l+1==2) return a[l][r]=a[r][l]=dep,void(0);
	int mid=l+r>>1;
	solve(l,mid,dep+1),solve(mid+1,r,dep+1);
	For(i,l,mid) For(j,mid+1,r) a[i][j]=dep;
}

int main(){
	int n=read();
	solve(1,n,1);
	FOR(i,1,n){
		For(j,i+1,n) printf("%d ",a[i][j]);
		puts("");
	}
}

Measured memory_bytes: 4568
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int K, S;
	cin >> K >> S;

	ll ans = 0;
	for (int x = 0; x <= S; x++)
	{
		for (int y = 0; y <= S - x; y++)
		{
			int z = S - x - y;

			if (x <= K && y <= K && z <= K)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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(){
    int n,k,sum=0;
    cin >> n >> k;
    vector<int> d(k),a(k*n,-100);
    vector<int> s(n+1);

    rep(i,k){
        cin>>d[i];
        int tmp;
        rep(j,d[i]){
            cin >> tmp;
            s[tmp]++;
        }
    }
    rep(i,n+1){
        if(i==0) continue;
        if(s[i]==0) sum++;
    }
    cout<<sum<< endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  
  //s->t
  for(int i=0;i<tx-sx;i++)cout<<"R";
  for(int i=0;i<ty-sy;i++)cout<<"U";
  //t->s
  for(int i=0;i<tx-sx;i++)cout<<"L";
  for(int i=0;i<ty-sy;i++)cout<<"D";
  //s->t
  cout<<"D";
  for(int i=0;i<tx-sx+1;i++)cout<<"R";
  for(int i=0;i<ty-sy+1;i++)cout<<"U";
  cout<<"L";
  //t->s
  cout<<"U";
  for(int i=0;i<tx-sx+1;i++)cout<<"L";
  for(int i=0;i<ty-sy+1;i++)cout<<"D";
  cout<<"R";
}




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

const int mxN = 2e5 + 5;
long long a[mxN], prefix[mxN], suffix[mxN];

int main() {
	int k, n;
	cin >> k >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	long long ans = 1e9;
	for(int i = 2; i <= n; ++i)
		prefix[i] = prefix[i - 1] + a[i] - a[i - 1];
	for(int i = n - 1; i; --i)
		suffix[i] = suffix[i + 1] + a[i + 1] - a[i];
	for(int i = 1; i <= n; ++i) {
		long long x = suffix[i] + (i == 1 ? 0 : a[1] + k - a[n] + prefix[i - 1]); // to the right
		long long y = prefix[i] + (i == n ? 0 : a[1] + k - a[n] + suffix[i + 1]); // to the left
		x = min(x, y);
		ans = min(ans, x);
	}
	cout << ans;
}


Measured memory_bytes: 8280
N = int(input())
S = list(input())

cum_wlist, cum_elist = [], []
cum_w, cum_e = 0, 0

for i in S :
    if i == "W" :
        cum_w += 1
    else :
        cum_e += 1
    cum_wlist.append(cum_w)
    cum_elist.append(cum_e)
    
min_change = N + 1

for i in range(N) :
    if S[i] == "W" :
        min_change = min(min_change, cum_wlist[i] -  1 + cum_elist[N - 1] - cum_elist[i])
    else :
        min_change = min(min_change, cum_wlist[i] + cum_elist[N - 1] - cum_elist[i])

print(min_change)

Measured memory_bytes: 20428
n = gets.to_i
n.times{
    s, d = gets.chomp.split.map(&:to_i)
    step = 0
    while s < d
        if s == 0
            q = 0
            q += 1 while (2 ** q) <= d
            s += (2 ** (q - 1))
        else
            q = 0
            q += 1 while s % (2 ** q) == 0
            (q - 1).downto(0){|q2|
                if s + (2 ** q2) <= d
                    s += (2 ** q2)
                    break
                end
            }
        end
        step += 1
    end
    puts step
}



Measured memory_bytes: 6872
#include<stdio.h>

	      
int main(){
  int i, left, right, mid, n, m, count = 0;
  scanf("%d", &n);
  int A[n];
  for(i = 0 ; i < n ; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &m);
  int B[m];
  for(i = 0 ; i < m ; i++){
    scanf("%d", &B[i]);
  }
  i = 0;
  for(i = 0 ; i < m ; i++){
    left  = 0;
    right = n;
    while(left < right){
      mid = (left + right) / 2;
      if(B[i] == A[mid]){
	count++;
	break;
      }
      else if(B[i] < A[mid]){
	right = mid;
      }
      else if(B[i] > A[mid]){
	left = mid + 1;
      }
      else break;
    }
  }
  printf("%d\n", count);
}



Measured memory_bytes: 2288
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;

  ll ans = K;

  if(N > 1){
    rep2(i, 1, N){
      ans *= (K - 1);
    }
  }

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


Measured memory_bytes: 256
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

void YES(bool ok){
    cout << (ok ? "AC" : "WA") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    bool ok = true;
    string s;cin >> s;
    auto check = [&](char c){
        ll t = c - 'a';
        if(t >= 0 && t < 26)return true;
        return false;
    };
    ll cnt = 0;
    ll n = s.size();
    rep(i,n){
        if(i == 0){
            ok &= s[i] == 'A';
            continue;
        }
        if(i >= 2 && i < n-1){
            if(s[i] == 'C')cnt++;
            else ok &= check(s[i]);
        }
        else{
            ok &= check(s[i]);
        }
    }
    ok &= cnt == 1;
    YES(ok);    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	char b='-';
	string s;
	bool flag=true;
	map<string,int>mp;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>s;
		if(s[0]!=b&&b!='-')flag=false;
		if(mp[s]++==1)flag=false;
		b=s.back();
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#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<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(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 NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
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;}

string S;

signed main(){
	cin>>S;
	cout<<S.substr(0,3)<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  int max_num = max(a,b);
  max_num = max(max_num,c);
  int max_sum = max_num * pow(2,k);
  if(max_num == a){
    max_sum = max_sum + b + c;
  }else if(max_num == b){
    max_sum = max_sum + a + c;
  }else if(max_num == c){
    max_sum = max_sum + a + b;
  }
  cout << max_sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <climits>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const set<A>& s) {
    for(auto it = s.begin(); it != s.end(); ++it) {
        output << *it << endl;
    }
    return output;
}

template<class A, class B>
ostream& operator << (ostream& output, const map<A, B>& m) {
    for(auto it = m.begin(); it != m.end(); ++it) {
        output << "[" << it->first << ", " << it->second << "]" << endl;
    }
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    long long n;
    cin >> n;
    long long ans = 1e15;
    for(long long i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ans = min(ans, ((i + (n / i)) - 2));
        }
    }   
    cout << ans << endl;
    return 0;
}

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

int main(){

    int n,l;
    cin >> n >> l;

    vector<string> s(n);

    rep(i,n)cin >> s[i];

    sort(s.begin(),s.end());

    rep(i,n){
        cout << s[i];
    }cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#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;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2||b%2||c%2){
        cout<<0<<endl;
        return 0;
    }
    if(a==b&&b==c){
        cout<<-1<<endl;
        return 0;
    }

    ll ans = 0;
    map<tuple<ll,ll,ll>,ll> m;
    while(true){
        ll a1=0,b1=0,c1=0;
        a1+=b/2+c/2;
        b1+=a/2+c/2;
        c1+=a/2+c/2;
        tuple<ll,ll,ll> m2 = make_tuple(a1,b1,c1);
        ans++;
       
            if(a1%2||b1%2||c1%2){
                cout<<ans<<endl;
                return 0;
            }
            m[m2]++;
        
        a=a1;
        b=b1;
        c=c1;

    }




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;

class Problem
{
private:
	// Variables
	int r, g, b;
	
public:
	// Methods
	void input ()
	{
		cin >> r >> g >> b;
	}
	
	void process ()
	{
		
	}
	
	void output ()
	{
		cout << ((g*10 + b & 3) ? "NO" : "YES") << endl;
	}
};

int main ()
{
	Problem problem;
	problem.input();
	problem.process();
	problem.output();
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

bool comp(p p1, p p2){
  return p1.second>p2.second; //終了時間遅い順
}

int main(){
  int n; cin >> n;
  vector<p> tasks(n);
  REP(i,n) cin >> tasks[i].first >> tasks[i].second;
  sort(tasks.begin(),tasks.end(),comp);
  ll t = tasks[0].second;
  REP(i,n){
    t -= tasks[i].first;
    if(i!=n-1&&t>tasks[i+1].second) t = tasks[i+1].second;
  }
  if(t>=0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;

long long gcd(long long x,long long y){
    if(y == 0) return x;
    return gcd(y,x%y);
}

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

  vector<int> A(N);
  vector<int> l(N);
  vector<int> r(N);
  REP(i, N) cin >> A[i];

  l[1] = A[0];
  r[N-2] = A[N-1];
  FOR(i, 2, N) l[i] = gcd(l[i-1], A[i-1]);
  RREP(i, N-2) r[i] = gcd(r[i+1], A[i+1]);

  int ans = 0;
  REP(i, N) ans = max(ans, gcd(r[i], l[i]));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int>p(a),q(b),r(c);
    rep(i,a)cin>>p[i];
    rep(i,b)cin>>q[i];
    rep(i,c)cin>>r[i];
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    rep(i,x)r.push_back(p[i]);
    rep(i,y)r.push_back(q[i]);
    sort(r.rbegin(),r.rend());
    ll ans=0;
    rep(i,x+y)ans+=r[i];
    cout<<ans<<endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  vector<int> par(N), deg(N);
  rep(i, 0, N + M - 1) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    G[s].push_back(t);
    deg[t]++;
  }
  queue<int> Q;
  rep(i, 0, N) if (!deg[i]) Q.push(i);
  while(!Q.empty()) {
    int v = Q.front(); Q.pop();
    for(auto p : G[v]) deg[p]--;
    for(auto p : G[v]) {
      if(!deg[p]) {
        Q.push(p);
        par[p] = v + 1;
      }
    }
  }
  rep(i, 0, N) cout << par[i] << endl;
  return 0;
}


Measured memory_bytes: 7040
#include <iostream>

using namespace std;

int N;
int H[100000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> H[i];
    H[0]--;
    for(int i=1;i<N;i++){
        if(H[i-1] > H[i]){
            cout << "No" << endl;
            return 0;
        }
        if(H[i-1] < H[i]) H[i]--;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#include<map>
#include <utility>
using namespace std;
//Emory "L" Blein
#define ll long long


int main() {
    int n,a,b,res=0;
    cin>>n>>a>>b;
    for(int i = 1; i<=n; i++){
        int s=0;
        int tt = i;
        while(tt>0){
            int t = tt%10;
            s+=t;
            tt/=10;
        }
        if(s>=a && s<=b){
            res+=i;
        }

    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
import sys
import bisect

input = sys.stdin.readline
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        l = L[i] + L[j]
        p = bisect.bisect_left(L, l)
        # print(p)
        ans += p - j - 1

print(ans)

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, k; cin>>n>>k;
  int ans = 0;
  rep(i,0,n) {
    int x; cin>>x;
    if(x>=k) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,o=0;
	bool n[1000000];
	for(int i=2;i<=999999;i++){
		n[i]=true;
	}
	n[0]=n[1]=false;
		for( int j=2;j*j<=999999;j++){
			if(n[j]){
				for(int k=j*2;k<=999999;k+=j){
				n[k]=false;
				}
			}
		}
		while(cin>>a){
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
	o=0;
		}
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		for(int i=0;i<n;i++) {
			int m=sc.nextInt();
			for(;;) {
				if(m%2==0) {
					m/=2;ans++;
				}else {
					break;
				}
			}
		}
	System.out.println(ans);
	}
}

Measured memory_bytes: 35104
#include <bits/stdc++.h>
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    double S = double(W) * double(H) / 2.0;
    int P = 0;
    if (x * 2 == W && y * 2 == H)
    {
        P = 1;
        cout << S << " " << P << endl;
        return 0;
    }
    cout << S << " " << P << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  long long n,d;
  cin >> n >> d;
  long long x,y;
  int ans=0;
  rep(i,n){
    cin >> x >> y;
    if(x*x+y*y<=d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int cnt[10];
int main() {
	int n;
	while (cin >> n, n) {
		memset(cnt, 0, sizeof(cnt));
		int b = 0;
		rep(i, 100) {
			char c; cin >> c;
			switch (c) {
			case 'M':cnt[i%n]++; break;
			case 'S':b += cnt[i%n] + 1; cnt[i%n] = 0; break;
			case 'L':cnt[i%n] += b + 1; b = 0; break;
			}
		}
		sort(cnt, cnt + n);
		rep(i, n)cout << cnt[i] << ' ';
		cout << b << endl;
	}
}

Measured memory_bytes: 3160
#include<stdio.h>

void call(int n){
  int i,x;

  for(i=1;i<=n;i++){
    x=i;
    if(x%3==0){
      printf(" %d",i);
    }else{
      for(;x;x/=10){
        if(x%10==3){
          printf(" %d",i);
          break;
        }
      }
    }
  }
  putchar('\n');
}

int main(void){
  int n;

  scanf("%d",&n);
  call(n);
  return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,i,j;
  while(1){
    cin >> h >> w;
      if(h==0 && w==0) break;
    for(j=1;j<=h;j++){
      for(i=1;i<=w;i++){
	if(j%2==1){
	  if(i%2==1) cout << '#';
	  else cout << '.';
	}else{
	  	  if(i%2==0) cout << '#';
		  else cout << '.';
	}
      
      }
      cout << endl;
    }
    cout <<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>//"scanf("%lf",&(double));printf("%f",(double));"
//#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include<string>//"reverse(s's it,s's it)"
//#include<functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include<cmath>//"abs" "sqrt"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);//Be careful in topcoder
#define ps push//stack,(priority) queue,//Be careful in topcoder.
#define fr front//queue//for priority, use top().//Be careful in topcoder.
typedef long long ll;//not necessarily//Be careful in topcoder.
typedef pair<int,int> pii;//Be careful in topcoder.
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

//#define MAX_M 100

int main(){
	int n,m,x;
	int y1=0,y2=0;
	scanf("%d%d%d",&n,&m,&x);
	//printf("in: finished\n");
	for(int i=0;i<m;++i){
		int a;
		scanf("%d",&a);
		if(a<x) ++y1;
		else ++y2;
	}
	printf("%d\n",min(y1,y2));
}

Measured memory_bytes: 256
import sys, heapq
from collections import defaultdict
from itertools import product, permutations, combinations
from bisect import bisect_left # bisect(list, value) -> index

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

N, M = map(int, input().split())
pS = [list(input().split()) for _ in range(M)]

ac_num = defaultdict(int) # number of AC : dict
wa_num = defaultdict(int) # number of WA : dict
wass = 0 # number of WA : int
for ps in pS:
    p, S = int(ps[0]), ps[1]
    # 一度問題pがACなら飛ばす
    if ac_num[p] == 1:
        continue
    else:
        if S == 'AC':
            ac_num[p] = 1
            # ACになるまでにWAになった数を記録
            wass += wa_num[p]
        elif S == 'WA':
            wa_num[p] += 1
    #print(ac_num, wa_num)

print(sum(list(ac_num.values())), wass)

Measured memory_bytes: 44464
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;

priority_queue<P1,vector<P1>,greater<P1> > que;


signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        int a,b;
        cin>>a>>b;
        que.push(P1(b,a));
    }
    int nowtime=0;
    bool ok=true;
    while(!que.empty()){
        P1 u=que.top();
        if(nowtime+u.second>u.first){
            ok=false;
            break;
        }
        nowtime+=u.second;
        que.pop();
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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


void solve(long long N){
    ll ans = 0;
    for(int i = 0;i <= N;i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 3760
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);

        int ss = a < b ? a : b;
        int bb = a < b ? b : a;
        if((bb-ss)%2==0){
            Console.WriteLine((bb-ss)/2+ss);
        }else{
            Console.WriteLine("IMPOSSIBLE");
        }
	}
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}
int gcd(int a, int b)
{
	if (a % b == 0) { return b; }
	else { return gcd(b, a % b); }
}
int ketawa(int a)
{
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0,ans=0;
string s, t;

bool hikaku(int i,string s,string t)
{
	if (s[i] > t[i])
		return true;
	else if (s[i] < t[i])
		return false;
	else
		return hikaku(i + 1, s, t);
}

int main()
{

	cin >> s >> t;
	
	if (s == t)
		cout << "EQUAL" << endl;
	else if (s.length() > t.length() )
		cout << "GREATER" << endl;
	else if (s.length() < t.length())
		cout << "LESS" << endl;
	else if(hikaku(0,s,t))
		cout << "GREATER" << endl;
	else
		cout << "LESS" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

template <class T = long long int>
class Bit {
    private:
    int len;
    T *arr;
    T init;

    public:
    Bit(int length, T initialValue = 0) : len(length), init(initialValue) {
        arr = new T[length + 1];
        for (int i = 0; i <= length; i++) {
            arr[i] = initialValue;
        }
    }
    ~Bit() {
        delete[] arr;
    }
    void update(int a, T newval) {
        for (int x = a; x <= len; x += x & -x) arr[x] = ((arr[x] > newval) ? arr[x] : newval);
    }
    T query(int a) const {
        T ret = init;
        for (int x = a; x > 0; x -= x & -x) ret = ((arr[x] > ret) ? arr[x] : ret);
        return ret;
    }
};

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    std::reverse(a.begin(), a.end());

    auto b(a);
    std::sort(b.begin(), b.end());
    b.erase(std::unique(b.begin(), b.end()), b.end());
    for (auto &e : a) e = std::lower_bound(b.begin(), b.end(), e) - b.begin() + 1;

    std::vector<int> dp(n);
    Bit<> bit(n + 10);
    dp[0] = 1;
    bit.update(a[0], 1);
    for (int i = 1; i < n; i++) {
        dp[i] = std::max(1ll, bit.query(a[i]) + 1);
        bit.update(a[i], dp[i]);
    }

    std::cout << *std::max_element(dp.begin(), dp.end()) << std::endl;

    return 0;
}


Measured memory_bytes: 2176
#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 DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(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 NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
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 X;

signed main(){
	cin>>X;
	int A=100;
	for(int i=0;;i++){
		if(A>=X){
			cout<<i<<endl;
			return 0;
		}
		A+=(int)((double)A*0.01);
	}
	return 0;
}


Measured memory_bytes: 3596
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    def f(a):
        if sum(a) == 0:
            return 0
        if min(a) == 0:
            i = a.index(0)
            return f(a[:i]) + f(a[i+1:])
        return f(list(map(lambda x: x-1, a))) + 1

    return f(a)



print(main())




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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 998244353;
//const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 1e6+5;
int dp[N], f[N];


void solve() {

  int n, ans = 0;
  cin>>n;
  vi a(n);
  rep(i,0,n)
    cin>>a[i], f[a[i]]++;
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
  trav(i,a)
    for(int j=2*i; j<N; j+=i)
      dp[j]=1;
  trav(i,a)
    ans+=(f[i]==1&&!dp[i]);
  cout<<ans;
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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


Measured memory_bytes: 20268
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
coupone = [list(map(int, input().split())) for _ in range(m)]

ans = min(A) + min(B)
for i in range(m):
    x, y, c = coupone[i]
    ans = min(ans, A[x-1]+B[y-1]-c)
print(ans)

Measured memory_bytes: 38560