akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


auto solve(long long N, std::vector<long long> s){
    sort(begin(s), end(s));
    auto acc =accumulate(begin(s), end(s), 0LL);
    if((acc % 10) != 0) {
        return acc;
    }

    for(const auto v : s) {
        if(((acc - v) % 10) != 0) {
            return acc - v;
        }
    }

    return 0LL;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> s(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&s[i]);
    }
    auto result = solve(N, std::move(s));
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans=a[0]-1;
  ll u=2;
  for (int i=1;i<n;i++){
    if (a[i]<u) continue;
    if (a[i]==u){
      u++;
      continue;
    }
    ans+=(a[i]-1ll)/u;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
from collections import defaultdict


def main():
    N, M, C = [int(q) for q in input().split()]
    B = [int(q) for q in input().split()]

    A = [
        [int(q) for q in input().split()]
        for _ in range(N)
    ]

    c = 0
    for ai in A:
        if sum([a * b for a, b in zip(ai, B)]) + C > 0:
            c += 1
    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3564
#include<stdio.h>
int main(void){
int r,c,a,aa,b;
int rc[101][101];
scanf("%d %d",&r,&c);
for(a=0;a<=r;a++)for(b=0;b<=c;b++)rc[a][b]=0;
for(a=0;a<=r;a++){
for(b=0;b<c;b++){
if(a<r){
scanf("%d",&rc[a][b]);
}
else{
for(aa=0;aa<r;aa++){
rc[a][b]+=rc[aa][b];
}
}
rc[a][c]+=rc[a][b];
}
}
for(a=0;a<=r;a++){
for(b=0;b<=c;b++){
printf("%d",rc[a][b]);
if(b!=c)printf(" ");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2028
def solver(A,B):
    
    A_before=sum(A)
    
    
    for target in range(n+1):
    
        
        if target>0 and B[target-1]>0:#i-1にゆうしゃがのこっているとき
            if A[target]<=B[target-1]:
                B[target-1]=B[target-1]-A[target]
                A[target]=0
                continue #B[target]が0になるまで
            else:
                A[target]=A[target]-B[target-1]
                B[target-1]=0
                
                
        if target < n:        
            if A[target] >= B[target]:#iにおけるモンスターの数>=勇者の数
                A[target]=A[target]-B[target]
                B[target]=0
                continue
            else:
                B[target]=B[target]-A[target]
                A[target]=0
                
                
            
    A_after=sum(A)
    
    return A_before-A_after
    
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
print(solver(A,B))


Measured memory_bytes: 18752
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define int long long
#define ll unsigned long long
#define ld long double
#define mx 100005
#define mod 1000000007
#define fr first
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int tc=1;

void solve(int kk)
{
//     ll n,five=0,three=0;
//     cin >> n;
//     ll t = n/3; /// 5
//
//     three = (t*(t+1))/2; /// 15
//     three*=3; /// 45
//
//     t = n/5; /// 3
//
//     five = (t*(t+1))/2; /// 6
//     five*=5; /// 30
//
//     t = n/15; /// 1
//
//     ll sum;
//     sum = (n*(n+1))/2; /// 120-45-30
//     cout << sum-three-five+(t*15) << "\n";
       int n;
       cin >> n;

       int sum=0;

       for(int i=1; i<=n; i++){
           for(int j=1; j<=n; j++){
               for(int k=1; k<=n; k++){
                    int gc = __gcd(i,j);
                    gc = __gcd(gc,k);
                    sum+=gc;
               }
           }
       }
       cout << sum << "\n";




    // puts("No");
}

signed main()
{
   //freopen("text.txt", "r", stdin);
   //freopen("text2.txt", "w", stdout);
   fast;
   int kk=0;
   //cin >> tc;
   //scanf("%d", &tc);

   while(++kk<=tc) solve(kk);

   return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	ll n,avg=0,ans=0;
	in(n);

	vll a(n);
	rep(i, 0, n) {
		in(a[i]);
		avg += a[i];
	}
	avg = round((double)avg / n);
	rep(i, 0, n) {
		ans += pow((a[i] - avg), 2);
	}
	outn(ans);
	return 0;

	}
	

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

using namespace std;

int main()
{
  int64_t n;

  cin >> n;

  int64_t j = n;
  int64_t x = 1;
  int64_t ans = 0;

  for(int64_t i = 1;
      i <= 5 && x <= n;
      ++i)
    {
      if(i % 2 == 1)
        {
          if (j / 10 == 0)
            {
              if(n != x * 10)
                {
                  ans += (n - x + 1);
                }
              else
                {
                  ans += (n - x);
                }
            }
          else
            {
              ans += ((x * 10) - x);
            }
        }
      j /= 10;
      x *= 10;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int a, b, c; CI a >> b >> c;
	int mmax = max(a, max(b, c));
	int mmin= min(a, min(b, c));
	for (;;) {
		if ((3*mmax -(a+b+c) )%2==0)break;
		mmax++;
	}


	CO((3 * mmax) - (a + b + c)) / 2 EN;

	return 0;
}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

A,B=[0],[0]

for i in range(n):
    A.append(A[i]+a[i])

for i in range(m):
    B.append(B[i]+b[i])

ans=0
j=m

for i in range(n+1):
    if A[i]>k:
        break
    while B[j]>k-A[i]:
        j-=1
    
    ans=max(ans,i+j)

print(ans)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin>>N>>K;
    vector<vi> p(N,vi(30));
    vector<vll> cost(N,vll(30));
    rep(i,N){
        cin>>p[i][0];
        p[i][0]--;
    }
    rep(i,N) cin>>cost[i][0];
    FOR(i,1,29){
        rep(j,N){
            cost[j][i]=cost[j][i-1]+cost[p[j][i-1]][i-1];
            p[j][i]=p[p[j][i-1]][i-1];
        }
    }
    auto f = [&](int s, int x){
        ll ret=0;
        int idx=0, cur=s;
        while(x){
            if (x&1){
                ret+=cost[cur][idx];
                cur=p[cur][idx];
            }
            idx++;
            x>>=1;
        }
        return pll(ret,cur);
    };
    ll ans=-1e9;

    rep(i,N){
        int cur=i;
        ll sum=0;
        FOR(k,1,min(N,K)){
            sum+=cost[cur][0];
            chmax(ans,sum);
            cur=p[cur][0];
        }
    }
    if (K>N)rep(i,N){
        ll sum; int cur;
        tie(sum,cur) = f(i,K-N);
        FOR(k,1,min(N,K)){
            sum+=cost[cur][0];
            chmax(ans,sum);
            cur=p[cur][0];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

	int n; cin >> n;
	vector<int> a(n);

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

	sort(a.begin(),a.end());
	
	int ansA = a[n-1];

	int h = ansA/2;
	int p;
	for (int i = 0;i < n;i++){
		if(a[i] > h) {p = i; break;}
	}

	if (h - a[p-1] < a[p] - h )p--;

	if (ansA == a[p]) p--;

	cout << ansA << ' ' << a[p] << endl;

	return 0;

}


Measured memory_bytes: 768
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int main() {
	int N, K, ans = 0, k = 0;
	cin >> N >> K;
	vector<int>v(N), b(K + 1);
	for (int i = 0; i < N; i++)cin >> v[i];
	int s = 0, t = 0;
	for (;;) {
		for (; t<N&&k<K; t++) {
			if (v[t] <= K&&++b[v[t]] == 1)k++;
		}
		if (k<K)break;
		for (; s<N&&k >= K; s++) {
			if (!ans || ans>t - s)ans = t - s;
			if (v[s] <= K && !--b[v[s]])k--;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3580
import java.util.*;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      int a = 0;
      int b = 0;
      int ss = 0;
      for(a=0;a<=100;a++){
        for(b=0;b<=100;b++){
          if(a+b==x && 2*a+4*b==y){
            ss = 1;
          }
        }
      }
      if(ss==1){
        System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }
      
     
    }
   
    
       
    
}

Measured memory_bytes: 27104
#include <iostream>

using namespace std;

int main()
{
	int N, M, capitalA, capitalB, frontierA, frontierB;
  	cin >> N >> M >> capitalA >> capitalB;
  	frontierA = capitalA;
  	frontierB = capitalB;
  	for (int i = 0; i < N; i++){
    	int cityA; cin >> cityA;
      	if (frontierA < cityA){
        	frontierA = cityA;
        }
    }
  	for (int i = 0; i < M; i++){
    	int cityB; cin >> cityB;
      	if (frontierB > cityB){
        	frontierB = cityB;
        }
    }
  	if (frontierA < frontierB){
    	cout << "No War";
    } else {
    	cout << "War";
    }
}

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

int main (){
    string s;
    cin >> s;
    int n = s.size();
    int count=0;
    int maxcount = 0;
    int point=0;
    while(point<n){
        if((s.at(point)=='A'||s.at(point) == 'C'||s.at(point) == 'G'||s.at(point) == 'T') && (point < n)){
            count++;
            point++;
        }else{
            count = 0;
            point++;
        }
        maxcount = max(maxcount,count);
    }

    cout << maxcount << endl;

}

Measured memory_bytes: 256
program main
    implicit none
    integer n,c1,c2
    integer(8) km, i
    integer(8), allocatable :: m(:), y(:)
    read*,n
    allocate(m(n+1), y(n))

    read*, m
    read*, y

    km = 0

    do i=1,n
        c1 = min(m(i), y(i))
        c2 = min(m(i+1), y(i)-c1)

        m(i) = m(i) - c1
        m(i+1) = m(i+1) -c2
        km = km + c1+ c2
    enddo
    print'(i0)', km
  
end program main

Measured memory_bytes: 2304
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18 + 69;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	if(n == 3) {
		cout << "2 5 63";
		return 0;
	}
	cout << "2 3 4 9 ";
	n-=4;
	ll X = 15;
	while(X+6<=30000&&n>1) {
		cout << X << " " << X+6 << "\n";
		X+=12;
		n-=2;
	}
	ll z = 6;
	while(z+4<=30000&&n>2) {
		cout << z << " " << z+2 << " " << z+4 << " ";
		z+=6;
		n-=3;
	}
	if(n==1) {
		cout << z;
	} else if(n==2) {
		cout << z+2 << " " << z+4;
	}
}


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

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

    vector<pair<long long, long long> > v;

    for(long long i = 0; i < n; i++){
        long long x, y;
        cin >> x >> y;
        v.push_back(make_pair(x, y));
    }

    map<pair<long long, long long>, long long> T;
    for(long long i = 0; i < n; i++){
        for(long long j = i+1; j < n; j++){
            long long dx = v[j].first - v[i].first;
            long long dy = v[j].second - v[i].second;
            if(dx < 0){
                dx = -dx;
                dy = -dy;
            }
            else if(dx == 0){
                if(dy < 0){
                    dy = -dy;
                }
            }
            
            if(T.find(make_pair(dx, dy)) == T.end()){
                T[make_pair(dx, dy)] = 1;
            }
            else{
                T[make_pair(dx, dy)]++;
            }
        }
    }

    map<pair<long long, long long>, long long>::iterator it;
    long long maxv = 0;
    for(it = T.begin(); it != T.end(); it++){
        maxv = max(maxv, it->second);
    }

    cout << n - maxv << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] nums = new int[N];
        for (int i = 0; i < N; i++) {
            nums[i] = sc.nextInt();
        }
        sc.close();
        System.out.println(garden(nums));
    }

   private static int garden(int nums[]) {
        int count = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            if (nums[i] > nums[i + 1]) {
               count = count + (nums[i] - nums[i +1]);
            }
        }
        return count + nums[nums.length - 1];
    }

}

Measured memory_bytes: 21972
main=do
 [k,s]<-map read.words<$>getLine
 print(f s k (k*k+2*k+1) [[x,y]|x<-[0..k],y<-[0..k]] 0)
  where f _ _ 0 _ a = a
        f s k n z a = f s k (n-1) (tail z) (if k>=(s-(sum(z!!0)))&&(s-(sum(z!!0)))>=0 then (a+1) else a)

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000009
# define pi acos(-1)
# define fi first
# define se second
using namespace std;


signed main()
{
    gok
    int k;
    cin>>k;
    int an=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int e=1;e<=k;e++)
            {
                int gg = __gcd(i,j);
                gg = __gcd(gg,e);
                an += gg;
            }
        }
    }

cout<<an;









      return 0;
    }


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


int main(void){
  int n; cin >> n;
  ll sum = 0;
  for(int i = 1; i <= n; i++){
    if(i % 5 != 0 && i % 3 != 0){
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


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

int main(){

  string s;
  cin >> s;
  
  int count = 0;
  
  if(s.at(0) == '1'){
    ++count;
  }
  if(s.at(1) == '1'){
    ++count;
  }
  if(s.at(2) == '1'){
    ++count;
  }
  
  cout << count << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<bitset>
#include<vector>
#include<queue>
#include<ext/pb_ds/priority_queue.hpp>
#include<set>
#include<map>
#include<math.h>
#include<set>
#define maxn 500005
#define lson (now<<1)
#define rson ((now<<1)|1)
typedef long long ll;
using namespace std;
using namespace __gnu_pbds; 
int main()
{
	int x;
	scanf("%d",&x);
	printf("%d\n",x+x*x+x*x*x);
}

Measured memory_bytes: 3832
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  ll a,b,n;
  ll ans = 0;
  cin >> a >> b >> n;
  if(b-1 <= n){
    ans = (ll)(a*(b-1)/b) - a*(ll)((b-1)/b);
  }else{
    ans = (ll)(a*n/b) - a*(ll)(n/b);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3760
A, B = map(int, input().split())
a0 = A % 2
b0 = B % 2
b0i = b0 ^ 1
A //= 2
B //= 2
f = (A % 2) ^ ((B % 2) ^ b0)
i = 1
while B > 0:
  a = (A % 2) & a0
  A //= 2
  b = ((B % 2) & b0i) ^ a
  B //= 2
  f += b * (2 ** i)
  i += 1
print(f)

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <unordered_set>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

int n, k;

int ans = 0;

signed main() {
  cin >> n >> k;
  int a = 0;
  if (k % 2 == 0) {
    for (int x = 1; x <= n; x++) {
      if (x % k == k / 2) {
        a++;
      }
    }
    ans += a * a * a;
  }
  a = n / k;
  ans += a * a * a;

  std::cout << ans << std::endl;
}


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

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N);
  for(ll i=0;i<N;i++)cin>>A.at(i);
  ll left=0;
  ll right=1000000001;
  while(right-left>1){
    ll mid=(right+left)/2;
    ll time=0;
    for(ll i=0;i<N;i++)time+=(A.at(i)-1)/mid;
    if(time>K)left=mid;
    else right=mid;
  }
  cout<<right<<endl;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  vs c(3); rep(i,3) cin >> c[i];
  rep(i,3) cout << c[i][i];
  cout << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left

n = int(input())
a = [int(s) for s in input().split()]
a.sort()
ai = a[-1]
j = bisect_left(a, ai // 2)
if j == 0:
    aj = a[j]
elif j == n-1:
    aj = a[j-1]
else:
    aj = a[j] if 2 * a[j] - ai <= ai - 2 * a[j-1] else a[j-1]
print(ai, aj)


Measured memory_bytes: 14056
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def count_group(self, n):
        return len({self.find(x) for x in range(1, n + 1)})

n, m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i == j:continue
        a, b = ab[j]
        uf.union(a, b)

    if uf.count_group(n) != 1:cnt += 1
print(cnt)


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

template <typename T>
T modpow(T base, T exp, T modulus) {
    base %= modulus;
    T result = 1;
    while (exp > 0) {
        if (exp & 1) result = (result * base) % modulus;
        base = (base * base) % modulus;
        exp >>= 1;
    }
    return result;
}

template <typename T>
T ipow(T base,T exp){
    T result = 1;
    while (exp > 0) {
        if (exp & 1) result =result * base;
        base = base * base;
        exp >>= 1;
    }
    return result;
}
void YES(bool f){
    if(f)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

int main(){
    int n,x;
    vector<int> m(4,0);
    for (int i = 0; i < 3; ++i) {
        cin>>x>>n;
        m[x-1]++;m[n-1]++;
    }
    int t=0;
    for (int j = 0; j < 4; ++j) {
        if(m[j]==2){
            ++t;
        }
    }
    YES(t==2);
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class HauntedHouse
    {
        public static int Main()
        {
            for (int i = 0; i < 9; i++)
            {
                var input = Console.ReadLine().Split(' ');
                string name = input[0];
                int am = int.Parse(input[1]);
                int pm = int.Parse(input[2]);

                int qty = am + pm;
                int amt = am * 200 + pm * 300;

                Console.WriteLine("{0} {1} {2}", name, qty, amt);
            }

            return 0;
        }
    }
}

Measured memory_bytes: 9020
import numpy as np

N = int(input())
H = np.array(list(map(int, input().split())))

ans = 0

while max(H):
    max_index = np.where(H == max(H))[0]
    ren_position = max_index - np.arange(len(max_index))
    ans += len(set(ren_position))

    H = np.where(H == max(H), max(H) - 1, H)

print(ans)


Measured memory_bytes: 12488
s = input()
t = input()
lenS = len(s)
lenT = len(t)

if lenS < lenT:
    print("UNRESTORABLE")
    exit()

ans = []
for i in range(lenS - lenT + 1):
    tmp = list(s)
    flag = True
    for j in range(lenS):
        if j < i or i + lenT <= j:
            if tmp[j] == '?':
                tmp[j] = 'a'
        else:
            if tmp[j] == '?':
                tmp[j] = t[j - i]
            elif tmp[j] != t[j - i]:
                flag = False
                break

    if flag:
        ans.append("".join(tmp))

if len(ans) == 0:
    print("UNRESTORABLE")
    exit()
print(sorted(ans)[0])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
int read(){
	char c;int x;while(c=getchar(),c<'0'||c>'9');x=c-'0';
	while(c=getchar(),c>='0'&&c<='9') x=x*10+c-'0';return x;
}
int n,f[MAXN],ans=1,pact;
int main()
{
	n=read();pact=0;
	for(int i=1;i<=n;i++) f[i]=read();
	for(int i=2;i<=n;i++){
		if(!pact){
			if(f[i]>f[i-1]) pact=1;
			if(f[i]<f[i-1]) pact=-1;
			continue;
		}
		if((f[i]<=f[i-1]&&pact<0)||(f[i]>=f[i-1]&&pact>0)) continue;
		ans++;pact=0;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int powi(int x,int n){if(n==0)return 1;return x*powi(x,n-1);}

ll N;
const int table[3]={3,5,7};

bool _753(ll k){
    int digit=log10(k)+1;
    bool c3=false,c5=false,c7=false;
    rep(i,digit){
        if(k%10==3) c3=true;
        else if(k%10==5) c5=true;
        else if(k%10==7) c7=true;
        k/=10;
    }
    return c3&&c5&&c7;
}

int def(ll x,ll m){
    int res=0;
    rep(i,3){
        ll k=10*x+table[i];
        if(k<=m){
            //cout<<k<<' '<<_753(k)<<endl;
            if(_753(k)) res++;
            res+=def(k,m);
        }
    }
    return res;
}

int main(){
    cin>>N;
    
    int ans=def(0,N);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;
	private Deque<String> d;
	private String str;

	private void mainrun() {
		scan = new Scanner(System.in);

		d = new LinkedList<>();

		while(scan.hasNext()) {
			str = scan.next();

			switch(str) {
			case "+":
			case "-":
			case "*":
				d.push(Calculation(Long.parseLong(d.pop()),
								   Long.parseLong(d.pop()),
								   str).toString());
				break;

			default:
				d.push(str);
			}
		}

		System.out.println(d.pop());
		scan.close();
	}

	private Long Calculation(long x,long y,String c) {
		switch(c) {
		case "+":
			return y + x;
		case "-":
			return y - x;
		case "*":
			return y * x;
		}
		return (long) 0;
	}
}



Measured memory_bytes: 26284
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int i = 0;
		while(s.charAt(i) != 'A')
			i++;
		int j = s.length() - 1;
		while(s.charAt(j) != 'Z')
			j--;
		System.out.println(j - i + 1);
	}
}

Measured memory_bytes: 14520
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K = int(readline().rstrip())
A, B = map(int, readline().split())

for i in range(A, B+1):
    if i % K == 0:
        print('OK')
        exit()

print('NG')

Measured memory_bytes: 9240
#include <stdio.h>
#include <algorithm>
typedef long long ll;

int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  std::sort(a, a + n);
  for(i = 1; i < n; ++i) a[i] += a[i - 1];
  for(i = n - 2; i >= 0; --i) if(a[i + 1] - a[i] > 2 * a[i]) break;
  printf("%lld", n - i - 1);
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

const ll MAXN = 110;
const ll MAXV = 100010;
ll dp[MAXN][MAXV];

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

    int n, W, tmpw, tmpv;
    vector<ll> w, v;
    cin >> n >> W;
    rep(i, n){
        cin >> tmpw >> tmpv;
        w.push_back(tmpw);
        v.push_back(tmpv);
    }

    rep(i, MAXN){
        rep(j, MAXV){
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;

    rep(i, n){
        rep(j, MAXV){
            if(j-v[i] >= 0) chmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
            chmin(dp[i+1][j], dp[i][j]);
        }
    }

    ll res = 0;
    rep(i, MAXV){
        if(dp[n][i] <= W) res = i;
    }

    cout << res << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  ll n,m,x,y;
  cin>>n>>m>>x>>y;

  ll a[n+2],b[m+2];

  a[0]=x;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }

  b[0]=y;
  for(int i=1;i<=m;i++)
  {
    cin>>b[i];
  }

  sort(a,a+n+1);
  sort(b,b+m+1);

  if(a[n]<b[0])
    cout<<"No War\n";
  else
    cout<<"War\n";

}

int main()
{
    su;
    ///tt
    f();
    return 0;
}

Measured memory_bytes: 3652
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
		   # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
LL concate(LL a, LL b)
{
	ostringstream os;
	os <<a <<b;
	istringstream is(os.str());
	LL c;
	is>> c;
	return c;
}
 
 
LL check(char c)
{
	return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}
LL mod = 1e9+7;
 
 
int main()
{
	//LL q,t;
	//cin>>t;
	//while(t--)
	//{
	   LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		LL aa[1000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivll;
		set<LL> :: iterator isll;
		VP :: iterator ivp;
 
		
		cin>>str>>str1>>str2;
		if(str[str.size()-1]==str1[0] && str1[str1.size()-1]==str2[0])cout<<yes<<endl;
		else cout<<no<<endl;
		
		
		
	exit()
 
 
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x;
    string s,s1,s2;
    cin >> s;   
    rep(i,3){
        if(s[i]=='o') c++;
    }
    cout << 700+100*c << endl;
    return 0;
} 

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=55;
using T = tuple<int,ll,ll>;
int n,m,s,mx;
ll ctr[mxn],tsct[mxn],dist[mxn][2505];
vector<T>adj[mxn];

struct state{
	int u; ll c,t;
	state(int u, ll c, ll t):u(u),c(c),t(t){};
	bool operator>(const state &s)const{return t>s.t;}
};

void dij(){
	for(int i=0; i<n; i++)
		for(int j=0; j<mx; j++)
			dist[i][j]=INF;
	
	priority_queue<state,vector<state>,greater<state>>pq;
	dist[0][s]=0LL;
	pq.push(state(0,s,0));
	while(!pq.empty()){
		state cur = pq.top(); pq.pop();
		for(T x:adj[cur.u]){
			int v; ll c,w;
			tie(v,c,w)=x;
			if(cur.c-c<0)continue;
			if(dist[v][cur.c-c]>dist[cur.u][cur.c]+w){
				dist[v][cur.c-c]=dist[cur.u][cur.c]+w;
				pq.push(state(v,cur.c-c,dist[v][cur.c-c]));
			}
		}
		int cnt=1;
		while(cur.c+cnt*ctr[cur.u]<=mx){
			if(dist[cur.u][cur.c+cnt*ctr[cur.u]]>dist[cur.u][cur.c]+cnt*tsct[cur.u]){
				dist[cur.u][cur.c+cnt*ctr[cur.u]]=dist[cur.u][cur.c]+cnt*tsct[cur.u];
				pq.push(state(cur.u,cur.c+cnt*ctr[cur.u],dist[cur.u][cur.c+cnt*ctr[cur.u]]));
			}
			cnt++;
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> n >> m >> s;
	mx = n*50;
	s=min(s,mx);
	int u,v,a,b;
	for(int i=0; i<m; i++){
		cin >> u >> v >> a >> b;
		u--; v--;
		adj[u].eb(v,a,b);
		adj[v].eb(u,a,b);
	}
	for(int i=0; i<n; i++)cin >> ctr[i] >> tsct[i];
	dij();
	vll ans(n,INF);
	for(int i=1; i<n; i++)
		for(int j=0; j<mx; j++)
			ans[i]=min(ans[i],dist[i][j]);
	for(int i=1; i<n; i++)
		cout << ans[i] << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int m,n;
char d[1000][1001];
char h[2][3];
char dd[3]={'J','I','O'};

int change(int x,int y,char c){
	if(c==d[x][y]) return 0;
	int res=0;
	for(int i=max(0,x-1);i<=min(x,m-1);i++) for(int j=max(0,y-1);j<=min(y,n-1);j++){
		int ok=1;
		for(int k=i;k<i+2;k++) for(int r=j;r<j+2;r++) if(d[k][r]!=h[k-i][r-j]) ok=0;
		if(ok) res--;
	}
	char p=d[x][y];d[x][y]=c;
	for(int i=max(0,x-1);i<=min(x,m-1);i++) for(int j=max(0,y-1);j<=min(y,n-1);j++){
		int ok=1;
		for(int k=i;k<i+2;k++) for(int r=j;r<j+2;r++) if(d[k][r]!=h[k-i][r-j]) ok=0;
		if(ok) res++;
	}
	d[x][y]=p;
	return res;
}

int main(){
	scanf("%d%d",&m,&n);
	for(int i=0;i<m;i++) scanf("%s",d[i]);
	scanf("%s%s",h[0],h[1]);
	int res=0;
	for(int i=0;i<m;i++) for(int j=0;j<n;j++) for(int k=0;k<3;k++) res=max(res,change(i,j,dd[k]));
	for(int i=0;i<m-1;i++) for(int j=0;j<n-1;j++){
		int ok=1;
		for(int k=i;k<i+2;k++) for(int r=j;r<j+2;r++) if(d[k][r]!=h[k-i][r-j]) ok=0;
		if(ok) res++;
	}
	printf("%d\n",res);
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void mmax(T &m, const T q) { if (m < q) m = q; }
template<typename T> void mmin(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


int main()
{
    lint T;
    cin >> T;
    lint X;
    cin >> X;
    cout << (double)T / X << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

    int MOD = 998244353;

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();

        long ans = 0;
        long col = m;

        Combi cb = new Combi(n-1, MOD);


        for (int x=n-1; 0<=x; x--) {
            long now = col % MOD;
//            System.out.println(now);
            now *= cb.nck(n-1, x);
            now %= MOD;
//            System.out.println(now);
            if (x <= k) {
                ans += now;
                ans %= MOD;
            }
            col *= (m - 1);
            col %= MOD;
        }

        System.out.println(ans);

//        System.out.println(new Combi(n, MOD).facts[n]);


    }

    public class Combi {
        int n;   //　要素数
        long MOD;
        long[] facts;

        public Combi(int n, long MOD){
            this.n = n;
            this.MOD = MOD;
            facts = new long[n+1];
            facts[0] = 1;
            for (int i=1; i<n+1; i++){
                facts[i] = facts[i-1]*i%MOD;
            }
        }

        public long modpow(long a, long b){  // 計算量はlog(MOD);
            if (b==0) return 1;
            else if (b==1) return a;
            long x = modpow(a, b/2);
            return b%2==0 ? x*x%MOD : x*(x*a%MOD)%MOD;
        }
        public long inv(long n){ // 逆元。x^(-1)≡x^(p-2) (MOD p)
            return modpow(n, MOD-2);
        }
        public long nck(int n, int k){
            return n<k ? 0: facts[n]*(inv(facts[n-k])*inv(facts[k])%MOD)%MOD;
        }
    }

}


Measured memory_bytes: 38528
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	REP(i,n) cin >> d[i];
	
	sort(d.begin(), d.end());
	
	cout << d[n/2]-d[n/2-1] << endl;
	
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1)res.emplace_back(n,1);
    return res;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> a;
    for(ll i=2;i<=55555;i++){
        auto v = factorize(i);
        if(v[0].first == i && (i-1)%5 == 0){
            a.push_back(i);
        }
    }
    //cout << a.size() << endl;
    rep(i,N){
        cout << a[i] << (i==N-1?"\n":" ");
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <deque>
#define ll long long

using namespace std;

struct lis {
	int key;
	struct lis* prev;
	struct lis* next;
};

lis* lst;

void init() {
	lst = (lis*)malloc(sizeof(lis));
	lst->key = -1;
	lst->prev = lst;
	lst->next = lst;
	return;
}


void insert(int x) {
	lis* n = (lis*)malloc(sizeof(lis));
	n->key = x;
	n->prev = lst;
	n->next = lst->next;
	lst->next->prev = n;
	lst->next = n;
	return;
}

void del(int x) {
	lis* cur = lst->next;
	while (cur->key > 0) {
		if (cur->key == x) {
			cur->prev->next = cur->next;
			cur->next->prev = cur->prev;
			return;
		}
		else {
			cur = cur->next;
		}
	}
	return;
}

void deleteFirst() {
	lst->next->next->prev = lst;
	lst->next = lst->next->next;
}

void deleteLast() {
	lst->prev->prev->next = lst;
	lst->prev = lst->prev->prev;
}

int main() {
	int n; cin >> n;
	init();
	for (int i = 0; i < n; i++) {
		char st[20]; scanf("%s", st);
		if (st[0] == 'i') {
			int ky; scanf("%d", &ky);
			insert(ky);
		}
		else if (strlen(st) < 8) {
			int ky; scanf("%d", &ky);
			del(ky);
		}
		else if (st[6] == 'F') {
			deleteFirst();
		}
		else deleteLast();
	}
	lis* cur = lst->next;

	if (cur->key < 0) {
		cout << endl;
		return 0;
	}
	cout << cur->key;
	cur = cur->next;

	while (cur->key > 0) {
		cout << " " << cur->key;
		cur = cur->next;
	}
	cout << endl;
	return 0;

}





Measured memory_bytes: 37512
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    ll a[N];
    bool flg = false;
    rep(i, N) {
        cin >> a[i];
        if(a[i] % 2 == 1) flg = true;
    }
    cout << ((flg) ? "first" : "second") << endl;
}


Measured memory_bytes: 1024