akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  int n=s.size();
  int ki=0,gu=0;
  vector<int> ans(n);
  rep(i,n){
    if(s[i]=='R'){
      if(i%2==0) gu++;
      else ki++;
    }
    if(s[i]=='L'&&s[i-1]=='R'){
      if(i%2==0){
        ans[i]+=gu; gu=0;
        ans[i-1]+=ki; ki=0;
      }
      else{
        ans[i]+=ki; ki=0;
        ans[i-1]+=gu; gu=0;
      }
    }
  }
  rep(i,n/2){
    swap(s[i],s[n-1-i]);
    swap(ans[i],ans[n-1-i]);
  }
  rep(i,n){
    if(s[i]=='L'){
      if(i%2==0) gu++;
      else ki++;
    }
    if(s[i]=='R'&&s[i-1]=='L'){
      if(i%2==0){
        ans[i]+=gu; gu=0;
        ans[i-1]+=ki; ki=0;
      }
      else{
        ans[i]+=ki; ki=0;
        ans[i-1]+=gu; gu=0;
      }
    }
  }
  rep(i,n/2){
    swap(s[i],s[n-1-i]);
    swap(ans[i],ans[n-1-i]);
  }
  rep(i,n){
    if(i==n-1){
      cout << ans[i] << endl;
      continue;
    }
    cout << ans[i] << " ";
  }
}

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

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

  int flg=0;
  for (int i=0; i<=n; i+=7) {
    if ((n-i)%4==0) flg=1;
  }
  for (int i=0; i<=n; i+=4) {
    if ((n-i)%7==0) flg=1;
  }

  if (flg) cout << "Yes";
  else cout << "No";
}

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() {

  int N, R;
  cin >> N >> R;
  if (N >= 10) {
    cout << R << endl;
  } else {
    cout << R + (100 * (10 - N)) << endl;
  }
}

Measured memory_bytes: 256
N,M,X = list(map(int, input().split()))
C = []
A = []
for i in range(N):
  temp = list(map(int, input().split()))
  C.append(temp[0])
  A.append(temp[1:])
moneylist = []
for i in range(2**N):
  Xtemp = []
  moneytemp = 0
  for j in range(M):
    Xtemp.append(0)
  for j in range(N):
    if((i >> j) & 1): #iを右にjビットシフトして、その最下位ビットが1かどうか判定
      for k in range(M):
        Xtemp[k] += A[j][k]
      moneytemp += C[j]
  flag = 0
  for j in range(M):
    if(Xtemp[j] < X):
      flag = 1
      break
  if(flag==0):
    moneylist.append(moneytemp)
  
if(len(moneylist)==0):
  print(-1)
else:
  print(min(moneylist))

Measured memory_bytes: 9248
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}
int main ()
{
	long long  n,m;
	long long t;
	scanf ("%lld%lld",&n,&m);
	t=(n-2)*(m-2);
	if (n==1&&m==1) printf ("1\n");
	else if (n==1&&m!=1) printf ("%lld\n",m-2);
	else if (m==1&&n!=1) printf ("%lld\n",n-2);
	else printf ("%lld\n",t);
	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
//#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int a,b,n;
    cin>>a>>b>>n;
    if(b==1){cout<<0<<endl;return 0;}
    
    if(n<b){
        cout<<a*n/b-a*(n/b)<<endl;
    }else{
        cout<<a*(b-1)/b<<endl;
    }

    return 0;
}


Measured memory_bytes: 3616
s = input()

f = s[:2]
l = s[2:]

if 0 < int(f) <= 12 and 0 < int(l) <= 12:
  print("AMBIGUOUS")
elif 0 < int(f) <= 12:
  print("MMYY")
elif 0 < int(l) <= 12:
  print("YYMM")
else:
  print("NA")

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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }

    int num = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] * 4 * m >= sum) {
            ++num;
        }
    }

    if (num >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
  string A, B;
  cin >> A >> B;
  if (A.size() > B.size())
  {
    cout << "GREATER";
    return 0;
  }
  else if (A.size() < B.size())
  {
    cout << "LESS";
    return 0;
  }
  else
  {
    for (int i = 0; i < A.size(); ++i)
    {
      if (A[i] > B[i])
      {
        cout << "GREATER";
        return 0;
      }
      else if (A[i] < B[i])
      {
        cout << "LESS";
        return 0;
      }
    }
    cout << "EQUAL";
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc){
        char[] ar = sc.nn().toCharArray();
        LinkedList<Integer> list = new LinkedList<>();

        for(char ch: ar){
            if(ch == 'B') list.pollLast();
            else list.add(ch - '0');
        }

        list.forEach(out::print);
    }

    static class MyScanner{
        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
        }

        MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc(){
            return nn().charAt(0);
        }

        int ni(){
            return Integer.parseInt(nn());
        }

        long nl(){
            return Long.parseLong(nn());
        }

        double nd(){
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
        }

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
        }

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

Measured memory_bytes: 27988
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const ll inf = 1e18L + 5;

int main() {
    IO;
    int n, m, a, b;
    vector<pair<ll, int> > v;
    for (ll i = 0; i <= 3982; i++) {
        v.emplace_back(i * i * i * i * i, i);
    }
    cin >> n;

//    n = rand() % m + 1;

    for (auto x: v) {
        for (auto y: v) {
//            cout << n << " = ";
            if(x.ff >= y.ff && x.ff - y.ff == n){
                cout << x.ff << ' ' << y.ff << '\n';
                cout << x.ss << " " << y.ss << '\n';
                return 0;
            }
            else if(x.ff <= y.ff && y.ff - x.ff == n){
                cout << y.ss <<  " " << x.ss << '\n';
                return 0;
            }
            else if((__int128)x.ff + y.ff == (__int128)n){
                cout << x.ss << " " << -y.ss << '\n';
                return 0;
            }
//                assert(abs(x - y) == n or (__int128) x + y == (__int128) n);
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(void)
{
	int n, x, a=0, i, j, k;

	while (1)
	{
		scanf("%d %d", &n, &x);

		if (n<3&&x==0)
		{
			break;
		}
		for ( i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				for (k = 1; k <= n; k++)
				{
					if (i != k && k != j && i != j)
					{
						if (i + j + k == x )
						{
							a++;
						}
					}
				}
			}
		}
		printf("%d\n", a/6);
		a = 0;

	}
	return 0;
}


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

ll gcd(ll c, ll d){
    if(c < d) swap(c, d);
    if(d == 0) return c;
    return gcd(c%d, d); 
}

ll f(ll x, ll lcm, ll c, ll d){
    ll res;
    res = x - x / c - x / d + x / lcm;
    return res;
}

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

    ll lcm = (C * D) / gcd(C, D);
    ll ans = f(B, lcm, C, D) - f(A - 1, lcm, C, D);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        vll a(1e5, 0), b(1e5, 0);
        a[1] = b[1] = 300000;
        a[2] = b[2] = 200000;
        a[3] = b[3] = 100000; 
        ll x,y;
        cin >> x >> y;
        ll ans = a[x] + b[y];
        if(x == y && x == 1){
                ans += 400000;
        }
        cout << ans << endl;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    println(if (n % s(n) == 0) "Yes" else "No")
}

fun s(n: Int): Int {
    var x = n
    var s = 0
    while (x > 0) {
        s += x % 10
        x /= 10
    }
    return s
}

Measured memory_bytes: 33564
n = int(input())
Work = [list(map(int,input().split())) for i in range(n)]
Work = sorted(Work,key=lambda x: x[1])+[[0,0]]
time = Work[0][1]
for i in range(n):
  if Work[i][0] <= time:
    time -= Work[i][0]
    time += Work[i+1][1]-Work[i][1]
  else:
    print('No')
    exit()
print('Yes')

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

int main(){
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    while(1){
        if(s.size()==0)break;
        else if(s.substr(0,5)=="maerd")s=s.substr(5,s.size()-5);
        else if(s.substr(0,7)=="remaerd")s=s.substr(7,s.size()-7);
        else if(s.substr(0,5)=="esare")s=s.substr(5,s.size()-5);
        else if(s.substr(0,6)=="resare")s=s.substr(6,s.size()-6);
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int INF=1000010000;
typedef long long ll;

int main() {
  int n,m;cin >> n >> m;
  vector<int> g[100100];
  vector<int> h(100100,0);
  for(int i=0; i<m; i++){
    int x,y;cin >> x >> y;
    g[x].push_back(y);
    h[y]++;
  }
  vector<int> start;
  for(int i=1; i<=n; i++){
    if(h[i]==0) start.push_back(i);
  }
  vector<int> dp(n+1,0);
  queue<int> q;
  for(auto s: start){
    q.push(s);
  }
  while(!q.empty()){
    int now=q.front();q.pop();
    for(auto next: g[now]){
      h[next]--;
      if(h[next]==0){
        dp[next]=max(dp[now]+1,dp[next]);
        q.push(next);
      }
    }
  }
  int ans=0;
  for(int i=1; i<=n; i++) ans=max(ans,dp[i]);
  cout << ans << endl;
  return 0;
}

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

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

    vector<ll> arr(n);
    ll s = 0;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        s += arr[i];
    }

    vector<int> mnt(n, 0);
    ll temp = 0;
    for (int i = 1; i < n - 1; i += 2) {
        temp += arr[i];
    }
    mnt[0] = s - 2*(temp);

    cout << mnt[0] << " ";
    for (int i = 1; i < n; i++) {
        mnt[i] = 2 * arr[i - 1] - mnt[i - 1];
        cout << mnt[i] << " ";
    }
    cout << endl;
}

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

int main() {
  int s;
  cin>>s;
  set<int> st;
  int cnt=1;
  while(true){
    auto r = st.insert(s);
    if(!r.second){
      cout<<cnt;
      break;
    }
    cnt++;
    if(s%2==0)s/=2;
    else s=s*3+1;
  }
  return 0;
}

Measured memory_bytes: 256
//AnkitCode99
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define all(v) (v.begin(),v.end())
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
using namespace std;
int main()
{
	fast;
 //   #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ll a,b,k;
	cin>>a>>b>>k;
	if(k>=a)
	{
		k=k-a;
		a=0;
		b=max(0LL,b-k);
	}
	else
	{
		a=a-k;
	}

	cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 384
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Ciの値でsortする、Tを0000で固定した後、最後に2**N倍
N = ir()
C = np.array(lr())
MOD = 10 ** 9 + 7
C.sort()
two_power = np.array([(1+N-i) * pow(2, (N-2), MOD) % MOD if i < N-1 else pow(2, i, MOD) for i in range(N)])
answer = (C * two_power % MOD).sum() * 2**N
print(answer%MOD)


Measured memory_bytes: 34492
#include <iostream>
#include <string>
#include <map>
#include <cctype>

using namespace std;
string str;

bool func(string s){
  map<char, bool> nmpp, mpp;

  for(int i = 0; i < s.size(); i++){
    if(s[i] == '~'){
      i++;
      nmpp[s[i]] = true;
      if(mpp[s[i]]) return false;
    } else if(isalpha(s[i])){
      mpp[s[i]] = true;
      if(nmpp[s[i]]) return false;
    }
  }

  return true;
}

int main()
{
  bool f;

  while(getline(cin, str) && str != "#"){
    string s;
    f = false;
    for(int i = 0; i < str.size(); i++){
      s = "";
      while(i < str.size() &&  str[i] != '|') s += str[i++];

      f = func(s);
      if(f) break;
    }

    cout << ((f)? "yes" : "no") << endl;
  }

  return 0;
}

Measured memory_bytes: 908
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
const ll INF = 1<<30;

int main(){
    ll X, t; cin >> X >> t;
    X -= t;
    (X >= 0) ? cout << X << endl : cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    vector<string>strings;
    int k;
    cin >> s >> k;
    REP(i,s.length()){
        FOR(j,1,k+1){
            if(i+j > s.length())break;
            string a = s.substr(i,j);
            strings.push_back(a);
        }
    }
    sort(ALL(strings));
    strings.erase(unique(ALL(strings)),strings.end());
    cout << strings[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
using namespace std;
int main(void){
    int h,w,a,ans=0,c[10][10];
    cin>>h>>w;
    for(int i=0;i<10;i++)for(int j=0;j<10;j++)cin>>c[i][j];
    for(int k=0;k<10;k++)for(int i=0;i<10;i++)for(int j=0;j<10;j++)c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){cin>>a;if(a!=-1)ans+=c[a][1];}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

char s[123];

int main()
{
  scanf("%s", s);
  for (int i=0; i<4; i++)
    printf("%c", s[i]);
  printf(" ");
  for (int i=4; i<12; i++)
    printf("%c", s[i]);
  printf("\n");

  return 0;
}


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

int main()
{

	int N, k = 1, c;
	cin >> N;
	vector<int> d(N);

	for (int i = 0; i < N; i++)
		cin >> d[i];
	sort(d.begin(), d.end());
	reverse(d.begin(), d.end());

	for (int i = 1, c = d[0]; i < N; i++)
	{
		if (c > d[i])
		{
			k++;
			c = d[i];
		}
	}
	cout << k << endl;
	
}


Measured memory_bytes: 256
import sys
S = input()
T = input()

S_len = len(S)
T_len = len(T)

if T_len > S_len:
    print("UNRESTORABLE")
    sys.exit()

#条件１に関して
candidate = []
for i in range(0, S_len-T_len+1):

    isOkay = True
    for j in range(T_len):
        if S[i+j] == "?":
            continue

        if S[i+j] == T[j]:
            continue
        else:
            isOkay = False

    if isOkay:
        candidate.append((S[0:i] + T + S[i+T_len:]).replace("?", "a"))

if len(candidate):
    candidate.sort()
    print(candidate[0])
else:
    print("UNRESTORABLE")


Measured memory_bytes: 9112
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define int long long
map<int,int>S[31];
bool used[200005]={};
int n;
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a; scanf("%d",&a);
		int b = 0;
		while(a%2 == 0){
			 a /= 2;
			 b++;
		}
		S[b][-1*a]++;
	}
	int ans = 0;
	for(int i=0;i<30;i++){
		for(map<int,int>::iterator it=S[i].begin();it!=S[i].end();it++){
				int cur = it->fi*-1;
				int cnt = it->sc;
				if(cnt == 0) continue;
				for(int j=0;j<=30;j++) if((1<<j) > cur){
					if(S[i].find(-(1<<j)+cur) != S[i].end()){
					    if(cur*2 != (1<<j)){
    						int A = min(S[i][-cur],S[i][-(1<<j)+cur]);
    						ans += A;
    						S[i][-cur] -= A;
    						S[i][-(1<<j)+cur] -= A;
					    }
					    else{
					        int A = S[i][-cur];
    						ans += A/2;
    						S[i][-cur] -= (A/2)*2;
					    }
					}
					break;
				}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 12800
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

a, b, k = [int(line) for line in readline().split()]

if ( k - a ) >= 0:
  k -= a
  a = 0
  if ( k - b ) >= 0:
    b = 0
  else:
    b -= k
else:
  a -= k
  
print('{} {}'.format(a, b))

Measured memory_bytes: 3064
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
#include <cmath>
#include <stack>
#include <bitset>

using namespace std;

#define int long long
#define MAX 1e18

signed main() {
    int r; cin >> r;
    cout << 2 * M_PI * r << endl;

}

Measured memory_bytes: 3776
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  int mx = max({a, b, c});
  if (mx == a) cout << "A" << endl;
  if (mx == b) cout << "B" << endl;
  if (mx == c) cout << "C" << endl;
  return 0;	
}


Measured memory_bytes: 3088
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
    double a, b, c;
    double PI = acos(-1);
    cin >> a >> b >> c;
    //面積
    cout << fixed << setprecision(5) << a * b * sin(c * PI / 180) / 2 << endl;
    //周の長さ
    cout << fixed << setprecision(5) << sqrt(a * a + b * b - 2 * a * b * cos(c * PI / 180)) + a + b << endl;
    //高さ
    cout << fixed << setprecision(5) << b * sin(c * PI / 180) << endl;
    return 0;
}


Measured memory_bytes: 3584
n, a, b = [int(i) for i in input().split()]
s = input()
count = 0
count_b = 0

for i in range(n):
  if s[i] == 'a' and count < a+b:
    count += 1
    print('Yes')
  elif s[i] == 'b' and count < a+b and count_b < b:
    count += 1
    count_b += 1
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 4016
a, b = map(int, input().split())
c = list(map(int, input().split()[:a]))
c.sort(reverse = True)
d = c[:b]
e = 0
for i in d:
    if i >= ((1/(4*b))*sum(c)):
        e += 1
if e==b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9128
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		int a = 0, b = 0;
		
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextInt() ) {
			a = scan.nextInt();
			b = scan.nextInt();
			
			int c = a + b;
			int i;
			
			for(i = 1; ; i++) {
				if(c < 10) {
					break;
				}
				c = c / 10;
				
			}
			
			System.out.println(i);
		}
		
	}
}

Measured memory_bytes: 18580
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string s1=ReadLine();
      string s2=ReadLine();
      string s3=ReadLine();
      
      WriteLine(s1.Substring(0,1)+s2.Substring(1,1)+s3.Substring(2,1));
    }
}

Measured memory_bytes: 25744
import copy

def main():
    n,m = list(map(int, input().split(' ')))
    ps = [[] for _ in range(n)]
    for i in range(m):
        p, y = list(map(int, input().split(' ')))
        ps[p-1].append((y, len(ps[p-1]), i))

    ans_ = [0 for _ in range(m)]

    ans =  copy.deepcopy(ps)
    for i in range(n):
        p = ps[i]
        sorted_ps = sorted(p)
        for j, sp in enumerate(sorted_ps):
            ans_[sp[2]] = '{0:06d}'.format(i+1) + '{0:06d}'.format(j+1)

    for r in ans_:
        print(r)



if __name__ == '__main__':
    main()


Measured memory_bytes: 55028
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//priority_queue <int, vector <int>, greater <int> > pq; ..for min heap
using namespace std;
#define MOD 1000000007
#define PI 3.14159265358979323846264
#define pii pair <int, int>
#define pipii pair <int, pair <int, int> > 
#define piipi pair <pair <int, int>, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORD(i, y, x) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, x;
double ans;
int main() {
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%d", &x);
        ans += 1.0 / x;
    }
    ans = 1 / ans;
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long

int main()
{
    string s;
    cin>>s;
    bool a = false;
    rep(i,3) {
        if (s[i] == '7')
            a = true;
    }
    if(a)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
}


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

int main()
{
	int N;
	char ex[256];
	int cnt[6] = {};
	string S;

	fill_n(ex, 256, 5);	
	ex['M'] = 0, ex['A'] = 1, ex['R'] = 2, ex['C'] = 3, ex['H'] = 4;

	cin >> N;
	for ( int i = 0; i < N; i++ ) {
		cin >> S;
		cnt[ex[S[0]]]++;
	}
	int64_t sum = 0;
	for ( int i = 0; i < 3; i++ ) {
		for ( int j = i + 1; j < 4; j++ ) {
			for ( int k = j + 1; k < 5; k++ ) {
				sum += (int64_t)cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << sum << endl;
	return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <numeric>
#include <algorithm>
using namespace std;

typedef long long ll;

int N, K;
vector<int> D;
map<int, int> t_max;
vector<int> max_val, max_pos;

void input_init(void) {
	cin >> N >> K;
	D.resize(N);
	for (int i = 0; i < N; ++i) {
		int t;
		cin >> t >> D[i];
		if (t_max.count(t) == 0)
			t_max.insert(make_pair(t, D[i]));
		else
			t_max[t] = max(D[i], t_max[t]);
	}
}

void value_check(void) {
	map<int, int>::iterator itr;
	for (itr = t_max.begin(); itr != t_max.end(); ++itr)
		max_val.push_back(itr->second);
	sort(max_val.begin(), max_val.end(), greater<int>());
	sort(D.begin(), D.end(), greater<int>());
	int sz = max_val.size();
	max_pos.resize(sz);
	int p = 0;
	for (int i = 0; i < N; ++i) {
		if (D[i] == max_val[p]) {
			max_pos[p] = i;
			++p;
			if (p >= sz) break;
		}
	}
}

ll solve(void) {
	ll point_d = accumulate(D.begin(), D.begin() + K, (ll)0);
	int cur_k = 0;
	for (int i = 0; i < (int)max_pos.size(); ++i) {
		if (max_pos[i] > K - 1) break;
		++cur_k;
	}
	ll point_k = (ll)cur_k * cur_k;
	ll max_v = point_d + point_k;
	int cur_p = K - 1;
	for (int k = cur_k + 1; k <= (int)max_pos.size(); ++k) {
		while (cur_p > 0) {
			if (binary_search(max_pos.begin(), max_pos.end(), cur_p) == true)
				--cur_p;
			else {
				point_d -= (ll)D[cur_p];
				point_d += (ll)max_val[k - 1];
				ll val = point_d + (ll)k * k;
				max_v = max(val, max_v);
				--cur_p;
				break;
			}
		}
	}
	return max_v;
}

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

	input_init();
	value_check();
	ll ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6268
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(void){
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    REP(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        uf.unite(a,b);
    }

    int ans=0;
    REP(i,n) ans=max(ans,uf.size(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4032
n = int(input())
ans = [0] * (n + 1)
m = 100
for i in range(1, m + 1):
  for j in range(1, m + 1):
    for k in range(1, m + 1):
      s = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if s <= n:
        ans[s] += 1
for i in range(1, n + 1):
  print(ans[i])


Measured memory_bytes: 9140
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    A_list = [int(i) for i in input().strip().split()]
    max = 10 ** 18
    ans = 1
    if 0 in A_list:
        return 0

    for A in A_list:
        ans *= A
        if ans > max:
            return -1
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 21596
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    string s;
    cin >> n >> s;
    rep(i, s.size())
    {
        int p = s[i] - 'A';
        p += n;
        p %= 26;
        cout << (char)('A' + p);
    }
    cout << endl;
}

Measured memory_bytes: 256
/*
	In the name of Allah.
*/
 
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define gap ' '
#define INF 999999
 
const int MAXN = 2 * 1e5 + 5;
int a[MAXN];

bool binarySearch(int l, int r, int x){
	while(l <= r){
		int mid = l+(r-l)/2;
		if(a[mid] == x){
			return true;
		}
		else if(a[mid] > x){
			return binarySearch(0, mid-1, x);
		}
		else{
			return binarySearch(mid+1, r, x);
		}
	}
	return false;
}
 
 
int main(){
	int x, n; cin >> x >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	sort(a, a+n);
	int j = 0, ans = 0, res = 100000;
	for(int i = -102; i <= 0; ++i){
		int k = min(res, abs(x-i));
		if(res != k){
			ans = i;
			res = k;
		}	
	}
	for(int i = 1; i <= 102; ++i){
		bool flag = binarySearch(0, n, i);
		if(flag == 0){
			int k = min(res, abs(x-i));
			if(res != k){
				ans = i;
				res = k;
			}	
		}
	}
	cout << ans << endl;


 
    return 0;
}



Measured memory_bytes: 3216
s = input()



odd_s = s[::2]
even_s = s[1::2]

odd_b = odd_s.count('0')
odd_w = odd_s.count('1')
even_b = even_s.count('0')
even_w = even_s.count('1')

change_num = min(odd_w + even_b, odd_b + even_w)


print(change_num)  
  



Measured memory_bytes: 3188
S = input()

S1 = S
count1 = 0
prev1 = '0'
for s in S1:
    if prev1 == s == '0':
        s = '1'
        count1 += 1
    if prev1 == s == '1':
        s = '0'
        count1 += 1
    prev1 = s

S2 = S
count2 = 0
prev2 = '1'
for s in S2:
    if prev2 == s == '0':
        s = '1'
        count2 += 1
    if prev2 == s == '1':
        s = '0'
        count2 += 1
    prev2 = s

print(min(count1, count2))

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

const int N = (int)1e5;

char s[N+5];

int main() {
    scanf("%s", s);
    for (int i=0; s[i]; i++) {
        if (i % 2 == 0) putchar(s[i]);
    }
    putchar('\n');
    return 0;
}


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

int main() {
    long n, d4=0, d2=0, d1=0;
    cin >> n;
    for (int i=0; i<n; i++) {
        long long ai;
        cin >> ai;
        if (ai % 4 == 0)
            d4++;
        else if (ai % 2 == 0)
            d2++;
        else
            d1++;
    }
    if (d4 >= d1 - 1) {
        if (d2 == 0 || d4 >= d1)
            puts("Yes");
        else
            puts("No");
    } else
            puts("No");
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end());
	if(sum % 2 == 0) {
		cout << sum / 2 << endl;
	}
	else {
		for(int i = 0; i < n; i++) {
			if(a[i] % 2 == 1) {
				cout << (sum - a[i]) / 2 << endl;
				return 0;
			}
		}
	}
	return 0;	
}



Measured memory_bytes: 3212
#include<stdio.h>
int main(){
    int S, h, m, s;
    scanf("%d", &S);
    h = S /3600;
    m = (S - 3600*h) / 60;
    s = S - 3600*h - 60*m;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2100
a, b = map(int, input().split())
"""s = bin(a)
t = bin(b)
s = s[2:]
t = t[2:]
cri = len(t)
s = (cri - len(s)) * "0" + s
q = 0
for i in reversed(range(len(s))):
    if i == len(s) - 1:"""
#F(A, B) = F(0, A − 1) ⊕ F(0, B),なぜなら n ⊕ n = 0
#任意の偶数 n について n ⊕ (n + 1) = 1

def F(x):
    if x == -1:
        return 0
    elif x % 2 == 1:
        if (x + 1) % 4 == 0:
            return 0
        else:
            return 1
    else:
        if x % 4 == 0:
            return x
        else:
            return 1 ^ x

ans = F(b) ^ F(a - 1)

print(ans)

Measured memory_bytes: 3064
#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template <std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <vector>
#include <iostream>
using namespace std;
using mint = modint<1000000007>;
int main() {
	int N;
	cin >> N;
	mint ans = 1;
	for (int i = 2; i <= N; ++i) {
		bool ok = true;
		for (int j = 2; j <= i - 1; ++j) {
			if (i % j == 0) {
				ok = false;
			}
		}
		if (ok) {
			int rem = N, sum = 0;
			while (rem > 0) {
				rem /= i;
				sum += rem;
			}
			ans *= sum + 1;
		}
	}
	cout << ans.get() << endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t N;

void solve()
{
    std::cin >> N;

	std::string ans;
	while (N > 0)
	{
		N--;
		ans += (char)('a' + (N % 26));
		N /= 26;
	}
	std::reverse(ans.begin(), ans.end());
	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  if(k%2 == 0) cout << (k/2) * (k/2 )<< endl;

  else cout << (k/2 + 1) * (k/2)<< endl;

  return 0;
}


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

int main() {
  int N, K, d, a;
  cin >> N >> K;
  int have[100] = {};
  for (int i=0; i<K; i++) {
    cin >> d;
    for (int j=0; j<d; j++) {
      cin >> a;
      a--;
      have[a]++;
    }
  }
  int ans = 0;
  for (int i=0; i<N; i++)
    if (have[i] == 0)
      ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

// {{{ Modint
// using mint = modint<1000000007>;
// mint x = 2;
// std::cout << x.a << std::endl;
template <std::int64_t M>
class modint {
 public:
  int64_t a;

  explicit constexpr modint(const int64_t x = 0) noexcept :
    a((x % M + M) % M) {}
  constexpr int64_t &value() noexcept { return a; }
  constexpr const int64_t &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= M) {
      a -= M;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += M;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % M;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    int64_t exp = M - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  constexpr modint pow(ll t) const {
    if (!t) return modint(1);
    modint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};
// }}}
// 組み合わせO(n)のc4_init実行後、O(1)でc4を実行
std::vector<ll> fac(3000000, 1), finv(3000000, 1), inv(3000000, 1);

void c4_init(ll m) {
    for (ll i = 2; i < 3000000; i++) {
        fac[i] = fac[i - 1] * i % m;
        inv[i] = m - inv[m%i] * (m / i) % m;
        finv[i] = finv[i - 1] * inv[i] % m;
    }
}

ll c4(ll n, ll k, ll m) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % m) % m;
}

using mint = modint<998244353>;
ll N, M, K;

signed main() {
  cin >> N >> M >> K;
  c4_init(998244353);
  mint ans;
  for (ll k = 0; k <= K; k++) {
    ans += mint(M) * mint(c4(N-1, k, 998244353)) * (mint(M-1).pow(N-1-k));
  }
  cout << ans.value() << endl;
  return 0;
}


Measured memory_bytes: 73316
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, C);
    ll ans;
    if (A & 1 or B & 1 or C & 1)
    {
        ans = 0;
    }
    else if (A == B and B == C)
    {
        ans = -1;
    }
    else
    {
        ans = 0;
        while (A % 2 == 0 and B % 2 == 0 and C % 2 == 0)
        {
            ll a = (B + C) / 2;
            ll b = (C + A) / 2;
            ll c = (A + B) / 2;
            A = a;
            B = b;
            C = c;
            ++ans;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main()
{
    int n,d,ans=0;
    cin>>n>>d;
    vector<vector<int>> a(n,vector<int>(d));
    rep(i,n) rep(j,d) cin>>a[i][j];
    rep(n1,n){
        for(int n2=n1+1;n2<n;n2++){
            ll sum=0;
            rep(d1,d){
                sum+=(a[n1][d1]-a[n2][d1])*(a[n1][d1]-a[n2][d1]);
            }
            bool r=false;
            for(int i=0;i<=sum;i++){
                if(i*i==sum){
                    r=true;
                    break;
                }
            }
            if(r==true) ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3596
N, M, Q = map(int, input().split())
from itertools import product

L = set()
def h(l):
    if len(l) == N:
        L.add(l)
        return
    s = 0
    if len(l) == 0:
        s = 1
    else:
        s = l[-1]
    for i in range(s, M+1):
        h(l + (i,))


h(())

z = []
for i in range(Q):
    a,b,c,d = map(int, input().split())
    z.append([a-1,b-1,c,d])

ans = 0


for l in L:
    t = 0
    for a,b,c,d in z:
        if l[b] - l[a] == c:
            t += d
    ans = max(ans, t)

print(ans)


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

using namespace std;

string shift(string s, int k) {
  string res = "";
  for (int i = 0; i < s.size(); i++) {
    if ('a' <= s[i] && s[i] <= 'z') {
      s[i] = (s[i] - 'a' + k) % 26 + 'a';
    }
    res += s[i];
  }
  return res;
}

int main(void) {
  string s;
  while (getline(cin, s)) {
    string w;
    for (int i = 0; i < 26; i++) {
      w = shift(s, i);
      if (w.find("the") != string::npos || w.find("this") != string::npos || w.find("that") != string::npos) {
        cout << w << endl;
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3072
import java.util.*;

public class Main{
	public static void main(String arg[]){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt();
		int t=sc.nextInt();
		if(n%x==0)
			System.out.println((t*(n/x)));
		else 
			System.out.println(t*((n/x)+1));
	}
}

Measured memory_bytes: 35652