akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

using int64 = long long;

int main() {
  string s;
  cin >> s;
  vector<int64> v(s.size());
  for (int64 i = 0; i < s.size(); ++i)
    v[i] = s[i] - '0';

  int64 sum = 0;
  for (int bits = 0; bits < (1 << (s.size() - 1)); ++bits) {
    int64 k = v[0];
    for (int64 i = 0; i < s.size() - 1; ++i) {
      if ((bits >> i) & 1) {
        sum += k;
        k = v[i + 1];
      } else {
        k = k * 10 + v[i + 1];
      }
    }
    sum += k;
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define endl        '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define N  300005
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";



// class MemoryGame{
// public:
// // vs construct(int n){
void solve(){
	string a,b;
	cin>>a>>b;
	// cout<<
	if(b.substr(0,sz(a))==a&&sz(b)==sz(a)+1){
		cout<<"Yes\n";
		return;
	}
	cout<<"No";

}
// };
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll TESTS=1,an=1;
    // cin>>TESTS;
    while(TESTS--){
        // cout<<"Case #"<<an<<": ";
        an++;
        solve();

    }
    return 0;
}           

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

int main(){
  int K;
  cin >> K;
  string S;
  cin >> S;
  int size = S.size();
  
  if(size <= K){
    cout << S << endl;
  }
  else{
    for(int i = 0; i < K; i++){
      cout << S[i];
    }
    cout << "..." << endl;
  }
  
 return 0;
  
}

Measured memory_bytes: 3568
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    static long dp[][];
    static long max(int pos , int sum , block arr[])
    {
       if(pos == arr.length || sum > 10000)
        return 0;
       
        if(dp[pos][sum] != -1)
        return dp[pos][sum];
        
        if(arr[pos].s >= sum)
        {
            dp[pos][sum] = Math.max(arr[pos].v+max(pos+1,sum+arr[pos].w,arr),max(pos+1,sum,arr));
        }
        
        else
        {
            dp[pos][sum] = max(pos+1,sum,arr);
        }
        return dp[pos][sum];
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		block arr[] = new block[n];
		for(int i = 0 ; i < n ; i++)
		{
		    arr[i] = new block(sc.nextInt(),sc.nextInt(),sc.nextInt());
		}
		
		Arrays.sort(arr,new Compare());
		dp = new long[n][10001];
		for(int i = 0 ; i < n ; i++)
		{
		    for(int j = 0 ; j <= 10000 ; j++)
		    {
		        dp[i][j] = -1;
		    }
		}
		System.out.println(max(0,0,arr));
	}
}

class block
{
    int w , s , v;
    public block(int w , int s , int v)
    {
        this.w = w;
        this.s = s;
        this.v = v;
    }
}

class Compare implements Comparator<block>
{
    public int compare(block a , block b)
    {
        return a.s+a.w-b.s-b.w;
    }
}


Measured memory_bytes: 140152
from operator import itemgetter

n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]

sortA = sorted(AB, key=itemgetter(0))
sortB = sorted(AB, key=itemgetter(1))

if n%2==1:
    print(sortB[n//2][1] - sortA[-n//2][0] + 1)

else:
    print(int(((sortB[n//2][1]+sortB[n//2-1][1])/2 - (sortA[n//2][0]+sortA[n//2-1][0])/2) / (1/2) + 1))

Measured memory_bytes: 51828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define dump(x) cerr << #x << " : " << x << '\n'

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, 0, N) cin >> S[i];
    map<string, int> ma;
    ll ans = 0;
    rep(i, 0, N) {
        sort(S[i].begin(), S[i].end());
        ma[S[i]]++;
        ans += (ma[S[i]] - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18176
#include <stdio.h>

long long attack_count(long long hp){
	if(hp == 1)return 1;
	return 2*attack_count(hp/2) + 1;
}

int main() {
	long long H;
	scanf("%lld", &H);
	printf("%lld\n", attack_count(H));
	return 0;
}

Measured memory_bytes: 128
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define debug(args...){ string _s = #args;replace(_s.begin(),_s.end(),',', ' ');stringstream _ss(_s);istream_iterator<string>_it(_ss);err(_it, args);}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb              push_back
#define eb              emplace_back
#define ff              first
#define ss              second
#define NL              printf("\n");
#define bug(a)          cout<<#a<<" "<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **



ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
bitset<N>B;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc=1,in,loc,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
//cin>>tc;
rep(t,tc)
{
    cin>>n;
    rep(i,n)
    {
        cin>>a;
        x[a]=i;
    }
    //rep(i,n)cout<<i<<" "<<x[i]<<endl;
    rep(i,n)
    {
        in=x[i];
        if(in>a)c++;
        else sum=max(sum,c),c=1;
        a=in;
        sum=max(sum,c);
    }
    //cout<<sum<<" sum c "<<c<<endl;
    cout<<n-sum<<endl;
}
}
    return 0;
}

/*


*/
/// Check for constraint 0 or 1?
/// Division MOD needs BigMod(a,n-2)
/// long long or double? sqrt or division will work fine??
/// sort(begin(v), end(v), [] (int a, int b) { return a > b; });    /// Lambda Function for manual Sort


Measured memory_bytes: 4352
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    int t; cin >> t;
    if(~t & 1) {
      if(!(t % 3 == 0 || t % 5 == 0)) {
        cout << "DENIED\n";
        return;
      }
    }
  }
  cout << "APPROVED\n";
}


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

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

    cout << (N / (D*2+1)) + bool(N%(D*2+1)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "abc" || s == "bac" || s == "cba" || s == "acb" || s == "bca" || s == "cab") {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]){cout<<"YES"<<endl;}
		else{cout<<"NO"<<endl;}
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, q;
  cin>>n>>q;
  
  string s;
  cin>>s;

  // 累積和
  vector<int> a(n+1, 0); // a[0] = 0 になる
  for (int i = 0; i < n ; ++i) {
    
    if (i+1<n and s[i] == 'A' and s[i+1] == 'C') a[i+1] = a[i] + 1;
    else a[i+1] = a[i];
  }
  
  rep(i,q){
    int l,r;
    cin>>l>>r;
    --l;
    --r;
    
    cout<<a[r]-a[l]<< endl;
  }
}

Measured memory_bytes: 3832
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num;
		int count;
		int p, c;

		while(true){
			num = sc.nextInt();
			count = sc.nextInt();
			if(num==0&&count==0) break;

			int[][] array = new int[2][num];

			for(int i=0; i<num; i++){
				array[0][i] = num-i;
			}

			for(int i=0; i<count; i++){
				p = sc.nextInt();
				c = sc.nextInt();
				System.arraycopy(array[0], p-1, array[1], 0, c);
				System.arraycopy(array[0], 0, array[1], c, p-1);
				System.arraycopy(array[0], p+c-1, array[1], p+c-1, num-p-c+1);
				System.arraycopy(array[1], 0, array[0], 0, num);
			}
			
			System.out.println(array[0][0]);
		}
	}
}

Measured memory_bytes: 36812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

vector<ll>par(2e5+10);
map<ll,ll> si;
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=i;
    si[i]++;
  }
}

ll root(ll x) {
  if(par[x]==x) {
    return x;
  }
  else {
    return par[x]=root(par[x]);
  }
}

ll size(ll x) {
  return si[root(x)];
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

void unite(ll x, ll y) {
  if(same(x,y)) return;
  ll temp=size(x);
  si[root(y)]+=temp;
  si[root(x)]=0;
  par[root(x)]=root(y);
}

int main() {
  ll n,m;
  cin >> n >> m;
  init(2*n);
  for(ll i=0;i<m;i++) {
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    unite(a,b+n);
    unite(b,a+n);
  }
  map<ll,ll> c;
  for(ll i=0;i<n;i++) {
    c[root(i)]++;
  }
  ll ans=1;
  if(c.size()==1) {
    ans=n*(n-1)/2;
  }
  else {
    for(auto p:c) ans*=p.second;
  }
  ans-=m;
  cout << ans << endl;
}

Measured memory_bytes: 14336
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int x, y, z;
	while (scanf("%d%d%d", &x, &y, &z), x|y|z)
	{
		float p = 1.0 / x;
		int v[4], e[51], a[51];
		for (int i = 0; i < x; ++i)
			scanf("%d", v + i);
		memset(e, 0, sizeof(e));
		for (int i = 0; i < z; ++i)
		{
			int t;
			scanf("%d", &t);
			scanf("%d%d", e + t, a + t);
		}
		int max_money = 0;
		for (int i = 0; i < y; ++i)
			if (e[i] == 2)
				max_money += a[i];

		static float dp[51][5001];
		for (int i = 0; i <= y; ++i)
			for (int j = 0; j <= max_money; ++j)
				dp[i][j] = 0;
		dp[0][0] = 1;
		for (int i = 0; i < y; ++i)
		{
			for (int j = 0; j <= max_money; ++j)
			{
				if (dp[i][j] == 0)
					continue;

				for (int k = 0; k < x; ++k)
				{
					int to = min(y, i + v[k]);
					int money = j;
					if (e[to] == 1)
						to = min(y, to + a[to]);
					else if (e[to] == 2)
						money += a[to];
					else if (e[to] == 3)
						money = max(0, money - a[to]);

					dp[to][money] += dp[i][j] * p;
				}
			}
		}

		float res = 0;
		for (int i = 0; i <= max_money; ++i)
			res += i * dp[y][i];

		printf("%d\n", (int)res);
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int N=2e5+5;
using namespace std;

int main()
{
    string s;cin>>s;
    ll ans=0;
    for(int i=0;i<s.size();i++)
    {
        ans+=((int)s[i]-'0');
    }
    if(ans%9==0) cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3716
#include <iostream>
using namespace std;
int main()
{
  int a,b,c,x;
  cin >> a >> b >> c >> x;

  int cnt = 0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k == x){
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
using namespace std;

const int INF = 1000000000;

int main(){
	int n,m,R;
	int dist[200][200];
	int r[8];
	scanf("%d%d%d",&n,&m,&R);
	for(int i=0;i<R;i++) scanf("%d",r+i);
	for(int i=0;i<R;i++) r[i]--;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j) dist[i][i] = 0;
			else dist[i][j] = INF;
		}
	}
	for(int i;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--; b--;
		dist[a][b] = dist[b][a] = c;
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int a[8];
	for(int i=0;i<R;i++) a[i] = i;
	int ans = INF;
	do{
		int tmp = 0;
		for(int i=0;i<R-1;i++){
			tmp += dist[r[a[i]]][r[a[i+1]]];
		}
		ans = min(ans,tmp);
	}while(next_permutation(a,a+R));
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) {
    cout << "Yay!" << endl;
  }else {
    cout << ":(" << endl;
  }
}   

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

int main() 
{
  int n, d;
  cin >> n >> d;
   
  int x[n][d];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }

  int count = 0;

  for (int y = 0; y < n; y++) {
    for (int z = y + 1; z < n; z++) {
      double a = 0;
      if (y == z) continue;
      for (int j = 0; j < d; j++) {
        a += (x[y][j] - x[z][j]) * (x[y][j] - x[z][j]);
      }
      if (sqrt(a) == floor(sqrt(a))) {
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a = 0;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n) a += s[i] - '0';
    cout << (a%9==0?"Yes":"No") << endl; 
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	string s="a == b";
	cin>>a>>b;
	if(a<b)s="a < b";
	else if(a>b) s="a > b";
	cout<<s<<endl;
}




Measured memory_bytes: 3176
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#include<cmath>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mkp(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=100010;
ll a[N];
int n;
int main()
{
    //IO;
    int d,t,s;
    cin>>d>>t>>s;
    int x=(d+s-1)/s;
    if(t>=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3616
#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() {
	ll D, T, S;
	cin >> D >> T >> S;
	if (D <= T * S) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}





void _main() {
        int n; cin >> n;
        vector<int> a(n); cin >> a;
        a.insert(a.begin(), 0);
        a.emplace_back(0);
        n += 2;
        int tot = 0;
        for (int i = 1; i < n; i++) {
                tot += abs(a[i] - a[i - 1]);
        }

        for (int i = 1; i < n - 1; i++) {
                cout << tot - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << '\n';
        }
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 4000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int ctoi(char c){return c - '0';}

bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  string s;cin>>s;
  vector<string> a;
  int ans = 0;
  rep(i,1000){
    int n1 = i % 10,n2 = (i/10)%10,n3 = i/100;
    bool b1,b2,b3;b1 = b2 = b3 = false;
    rep(i,n){
      if(b1){
        if(b2){
          if(n3 == ctoi(s[i]))b3 = true;
        }
        if(n2 == ctoi(s[i]))b2 = true;
      }
      if(n1 == ctoi(s[i]))b1 = true;
    }
   
    ans += (b1&&b2&&b3);
  }
  print(ans);
  return 0;
} 

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] AmB = new int[N];
		//int[] BmA = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = scan.nextInt();
			B[i] = scan.nextInt();
			AmB[i] = A[i]+B[i];
			//BmA[i] = B[i]-A[i];
		}
		Integer[] AmBindex = argsort(AmB);
		//int num = N%2==0? N/2-1 : N/2;
		long scoreA = 0;
		//int scoreB = 0;
		for(int i=0;i<N;i++) {
			if (i%2==0) scoreA += A[AmBindex[i]];
			else scoreA -= B[AmBindex[i]];
		}
		System.out.println(scoreA);
	}
	
	public static Integer[] argsort(final int[] a) {
        Integer[] indexes = new Integer[a.length];
        for (int i = 0; i < indexes.length; i++) {
            indexes[i] = i;
        }
        Arrays.sort(indexes, new Comparator<Integer>() {
            @Override
            public int compare(final Integer i1, final Integer i2) {
                return -1 * Integer.compare(a[i1], a[i2]);
            }
        });
        return indexes;
    }
}

Measured memory_bytes: 91168
n=int(input())
l=[]
for i in range(n):
    s=list(input())
    l.append(s+s)
ans=0
for i in range(n):
    f=0
    for h in range(n):
        for w in range(n):
            #0,0+i 1,1+i h,h+i
            if l[h][w+i]!=l[w][h+i]:
                f+=1
    if f==0:
        ans+=1
print(ans*n)


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

int fx(int x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

int main() {
  int n;
  cin >> n;
  string harshad = "No";
  if (n % fx(n) == 0) harshad = "Yes";//fx
  
  cout << harshad;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define pi 3.14159265358979323846
using namespace std;
const int N = 3010;
int n , L;
int t[N];
int main()
{
	scanf("%d%d" , &n , &L);
	for(int i = 1 ; i <= n ; ++i) scanf("%d" , &t[i]);
	double ansx = 0 , ansy = 0;
	for(int i = 1 ; i <= n ; ++i)
		for(int j = i + 1 ; j <= n ; ++j)
		{
			double tmp = pi * (t[i] + t[j]) / L;
			ansx += cos(tmp) * (n - 2 * (j - i - 1) - 2);
			ansy += sin(tmp) * (n - 2 * (j - i - 1) - 2);
		}
	ansx /= (double)n * (n - 1) * (n - 2) / 6.0;
	ansy /= (double)n * (n - 1) * (n - 2) / 6.0;
	printf("%.10f %.10f" , ansx , ansy);
	return 0;
}

Measured memory_bytes: 512
n = int(input())
words = []
for _ in range(n):
    words.append(input())

sets = set(words)
if len(sets) != len(words):
    ans = 'No'
else:
    for i in range(1, n, 1):
        if words[i-1][-1] != words[i][0]:
            ans = 'No'
            break
        else:
            ans = 'Yes'

print(ans)

Measured memory_bytes: 9096
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

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

  ll ans = min(a*b, a*c);
  chmin(ans, b*c);
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long lint;

using namespace std;

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

	// yyyy/mm/dd

	int y = stoi(S.substr(0, 4));
	int m = stoi(S.substr(5, 2));

	if ((y <= 2019) && (m <= 4))
	{

		cout << "Heisei" << endl;
	}
	else
	{
		cout << "TBD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  double f = n/3.0;
  double ans = f*f*f;
  printf("%.10lf",ans);
  return 0;
}


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

int main() {
	string x,ans,temp;
	int s = 0;
	cin >> x;
	for (unsigned i = 0; i < x.size(); i++) {
		if (x[i] == 'S') {
			s++; temp += 'S';
		}
		else if (x[i] == 'T' && s == 0) {
			ans += 'T';
		}
		else {
			s--; temp.erase(temp.size() - 1);
		}
	}
	ans += temp;
	cout << ans.size() << endl;
	return 0;
}

Measured memory_bytes: 900
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var a = r[0].Long();
            var b = r[1].Long();
            var c = r[2].Long();
            var k = r[3].Long();

            long ans = 0;

            if (a >= k)
            {
                ans += k;
                k = 0;
            }
            else
            {
                ans += a;
                k = k - a;
            }

            if (k == 0)
            {
                WriteRead(ans);
                return;
            }

            if (b >= k)
            {
                k = 0;
            }
            else
            {
                k = k - b;
            }

            if (k == 0)
            {
                WriteRead(ans);
                return;
            }

            if (c >= k)
            {
                ans -= k;
                k = 0;
            }
            else
            {
                ans -= c;
                k = k - c;
            }

            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 17848
#include<bits/stdc++.h>
 using namespace std;
 
 #define     gcd(a,b)      __gcd(a,b)
 #define     lcm(a,b)     (a*(b/gcd(a,b)))
 #define     all(x)           (x).begin(), (x).end()
 #define     sz(x)           (int)x.size()
 #define     op()            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 #define     fraction()     cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
 #define      endl          "\n"
 
 typedef long long int ll;
 
 const double PI = acos(-1);
 const double eps = 1e-9;
 
 int main()
 {
    op();
    int k;
    cin >> k;
    string s = "ACL";
   string ss = "";
    for (int i = 0; i < k; ++i)
    {
      ss += s;
    }
    cout << ss << endl;



 }

Measured memory_bytes: 3644
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=5e5+5;




int main()
{ 

IOS;

ll n;cin>>n;

vl an,ap;

FOR(i,n){
  ll x;cin>>x;
  if(x>=0)ap.pb(x);
  else an.pb(x);
}

if(sz(ap)){

sort(all(an));

sort(all(ap));

vpll ans;

ll ret=ap[0];

//if(sz(an)>=1){
for(int i=0;i<sz(an);i++){
  if(i==sz(an)-1&&sz(ap)>1){
ans.pb({an[i],ret});
ret=an[i]-ret;
continue;  
  }
  ans.pb({ret,an[i]});
  ret-=an[i]; 

}

for(int i=1;i<sz(ap);i++){
  if(i==sz(ap)-1){
    ans.pb({ap[i],ret});
    ret=ap[i]-ret;
    continue;
  }
  ans.pb({ret,ap[i]});
  ret-=ap[i];
}

cout<<ret<<endl;

for(auto p:ans){
  d2(p.ff,p.ss);
}

return 0;

///}

}

else{

sort(all(an));

rev(an);

ll ret=an[0];

vpll ans;

for(int i=1;i<sz(an);i++){
  ans.pb({ret,an[i]});
  ret-=an[i];
}

cout<<ret<<endl;

for(auto p:ans)d2(p.ff,p.ss);

return 0;
}





//end_routine();

return 0;
 
}


Measured memory_bytes: 7152
#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 n;
string s;

bool check(int a, int b, int c) {
    int idx = 0;
    bool truth = false;
    rep(i, n) {
        if (s[i] == (a + '0')) {
            idx = i;
            truth = true;
            break;
        }
    }
    if (!truth) return false;
    truth = false;
    for (int i = idx+1; i < n; i++) {
        if (s[i] == (b + '0')) {
            idx = i;
            truth = true;
            break;
        }
    }
    if (!truth) return false;
    truth = false;
    for (int i = idx+1; i < n; i++) {
        if (s[i] == (c + '0')) {
            truth = true;
            break;
        }
    }

    return truth;
}

void solve() {
    cin >> n >> s;

    int ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) if (check(i, j, k)) ans++;
    cout << ans << endl;

}

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


Measured memory_bytes: 3600
#include<stdio.h>

    int main(){
    int n,s[100];
    int sum = 0;
    int min=101;

    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
    scanf("%d",&s[i]);
    sum = sum + s[i];
        if(min>s[i] && s[i]%10 != 0){
        min = s[i];   
        }
    }

    if(sum%10 != 0){
    printf("%d",sum);
    }else{

    if(min != 101){
    printf("%d",sum-min);
    }else{
    printf("0");
    }
      
    }
    return 0;

    } 

Measured memory_bytes: 128
#
import sys
import math
import numpy as np
import itertools

# いくつか入力
n,k = (int(i) for i in input().split())  

if (n-2)*(n-1) // 2  < k:
    print('-1')
    exit()

m = n*(n-1)//2 -k

print(m)

u=0
v=1
for i in range(m):
    print(u+1,v+1)
    v += 1
    if v==n:
        u += 1
        v = u + 1




Measured memory_bytes: 12904
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 207;
int dist[N][N];
string a[N];

vector <ii> v = { {0, 1}, {1, 0} };
int n, m;
void bfs() {

    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            dist[i][j] = N * N;

    deque <ii> q;
    q.push_back(mp(0, 0));
    dist[0][0] = a[0][0] == '#';
    while (q.size()) {
        auto p = q.front(); q.pop_front();

        //cout << p.f << ' ' << p.s << ' ' << dist[p.f][p.s] << endl;

        for (auto e : v) {
            int x = p.f + e.f, y = p.s + e.s;
            if (0 <= x && x < n && 0 <= y && y < m) {
                int nn = dist[p.f][p.s] + (a[p.f][p.s] == '.' && a[x][y] == '#');
                if (nn < dist[x][y]) {
                    dist[x][y] = nn;
                    if (a[p.f][p.s] == '.' && a[x][y] == '#')
                        q.push_back(mp(x, y));
                    else
                        q.push_front(mp(x, y));
                }
            }   
        }   
    }   
    cout << dist[n - 1][m - 1] << endl;
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    bfs();            
}   

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n; cin>>n;
	ll x[20], y[20], p[20];
	for(int i=0; i<n; i++){
		cin>>x[i]>>y[i]>>p[i];
	}
	ll mnx[16][1<<15], mny[16][1<<15];
	for(int i=0; i<n; i++){
		for(int j=0; j<(1<<n); j++){
			if(j&(1<<i)) mnx[i][j]=0, mny[i][j]=0;
			else{
				mnx[i][j]=abs(x[i]), mny[i][j]=abs(y[i]);
				for(int k=0; k<n; k++){
					if(j&(1<<k)){
						mnx[i][j]=min(mnx[i][j], abs(x[i]-x[k]));
						mny[i][j]=min(mny[i][j], abs(y[i]-y[k]));
					}
				}
			}
		}
	}
	ll ans[20];
	for(int i=0; i<=n; i++) ans[i]=1e18;
	for(int i=0; i<(1<<n); i++){
		int c=popcount(i);
		for(int j=i; j>=0; j=(j-1)&i){
			ll s=0;
			for(int k=0; k<n; k++){
				if(!(i&(1<<k))){
					s+=min(mnx[k][j], mny[k][i^j])*p[k];
				}
			}
			ans[c]=min(ans[c], s);
			if(j==0) break;
		}
	}
	for(int i=0; i<=n; i++) cout<<ans[i]<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i=0;i<N;i++){
  cin >> p.at(i);
  } 
  vector<int> q(N);
  for (int i=0;i<N;i++){
  cin >> q.at(i);
  }
  int P=0,Q=0; 
  do {
    P++;
  } while (next_permutation(p.begin(), p.end()));
  
  do {
    Q++;
  } while (next_permutation(q.begin(), q.end()));
  int ans=max(P,Q)-min(P,Q);
  cout << ans << endl;
}

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

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

const ll mod = 998244353;
template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
      return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inv();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
    
  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  
  static int get_mod() { return mod; }
};
 
using mint = ModInt<mod>;

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  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;
  }
}

// 二項係数計算
long long 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;
}

int main() {
  // 前処理
  COMinit();

  // 計算例
  ll N,M,K;
  cin >> N >> M >> K;

  mint ans = 0;
  for(ll i = 0; i <= K; i++){
    mint tmp = COM(N-1, i);
    mint m = M;
    tmp *= m;
    tmp *= (m-1).pow(N-1-i);
    ans += tmp;
  }
  cout << ans << endl;

}




Measured memory_bytes: 15576
N = int(input())
lis = list(map(int,input().split()))
current = 0
ans = 0
positions = [-1]
for i in range(N):
  if lis[i] - current == 1:
    positions.append(i)
    current = lis[i]
if len(positions) == 1:
  print(-1)
else:
  if positions[len(positions)-1] == N-1:
    for j in range(len(positions)-1):
      ans += positions[j+1] - positions[j] - 1
    print(ans)
  else:
    positions.append(N)
    for g in range(len(positions)-1):
      ans += positions[g+1] - positions[g] - 1
    print(ans)

    

Measured memory_bytes: 26840
#include <stdio.h>

int main(void)
{
	/*?????°??£?¨?*/
	int A[100][100];
	int b[100];
	int c,i,j,n,m;
	
	/*??\???*/
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	
	/*????????????,??????*/
	for(i=0;i<n;i++){
		c=0;
		for(j=0;j<m;j++){
			c+=A[i][j]*b[j];
		}
		printf("%d\n",c);
	}
	
	return 0;
}

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

int main() {
   int k, x;
   cin >> k >> x;

   string ans = (500 * k >= x) ? "Yes" : "No";

   cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int):
    ans = 0
    for i in range(N+1):
        if len(str(i))%2 == 1:
            ans += 1

    print(ans-1)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
a,b,c = map(int,input().split())
d = [a,b,c]
d.sort()
x,y = d[:-1]
m = d[-1]

cnt = m-y
x += cnt
y += cnt
if (y-x) % 2 == 1:
    cnt += (y+1-x)//2 + 1
else:
    cnt += (y-x)//2
    
print(cnt)

Measured memory_bytes: 3064
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		//入力(基本)
		String s = br.readLine();

		//文字列きりだし
		String new_str1 = s.substring(2, 5);

		System.out.print(s.substring(0, 4));
		System.out.print(" ");
		System.out.print(s.substring(4, 12));

		System.out.println("");             //画面表示

    }
}



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

int main(){
  int N;
  cin >> N;
  int V[N];
  rep(i, N){
    cin >> V[i];
  }
  sort(V, V+N);
  double ans = (V[0]+V[1]) / 2.0;
  rep(i, N-2){
    ans = (ans + V[i+2]) / 2.0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3768
fun main(args: Array<String>) {
    val price = readLine().orEmpty().toLong()
    var balance = 0L
    var glad = 0L


    if(price >= 500){
        glad += (price / 500) * 1000
        balance = price % 500
        if(balance >= 5){
            glad += (balance / 5) * 5
        }
    }else{
        glad += (price / 5) * 5
    }
    

    println(glad)
}

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

int main(){
  int A, B;
  cin >> A >> B;
  
  int k;
  if (A-2 >= B){
    k = A*2-1;
  }
  else if (A+1 == B){
    k = A+B;
  }
  else if (A == B){
    k = A+B;
  }
  else if (A == B+1){
    k = A+B;
  }
  else if (A <= B-2){
    k = B*2-1;
  }
   cout << k;
}

Measured memory_bytes: 256