akhauriyash/Code-Regression huggingface dataset:
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 2005
#define oo 2000000007
#define EPS 1e-9
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, m, q, a[maxN][maxN], f[maxN][maxN], fh[maxN][maxN], fv[maxN][maxN];
char s[maxN][maxN];

int main () {
    scanf("%d%d%d", &n, &m, &q);
    fto(i, 0, n-1) scanf("%s", s[i]);
    fto(i, 1, n) fto(j, 1, m) a[i][j] = s[i-1][j-1]-'0';

    fto(i, 1, n) {
        fto(j, 1, m) {
            f[i][j] = f[i-1][j] + f[i][j-1] - f[i-1][j-1] + a[i][j];
            fh[i][j] = fh[i-1][j] + fh[i][j-1] - fh[i-1][j-1] + (a[i][j-1] && a[i][j]);
            fv[i][j] = fv[i-1][j] + fv[i][j-1] - fv[i-1][j-1] + (a[i-1][j] && a[i][j]);
        }
    }

//    fto(i, 1, n) {
//        fto(j, 1, m) printf("%d ", fh[i][j]);
//        puts("");
//    }

    fto(i, 1, q) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

        int c = f[x2][y2] - f[x1-1][y2] - f[x2][y1-1] + f[x1-1][y1-1];
        int ch = fh[x2][y2] - fh[x1-1][y2] - fh[x2][y1] + fh[x1-1][y1];
        int cv = fv[x2][y2] - fv[x1][y2] - fv[x2][y1-1] + fv[x1][y1-1];
        printf("%d\n", c-ch-cv);
    }

    return 0;
}


Measured memory_bytes: 68480
import heapq
n = int(input())

arr = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
ans = 0
q = []
heapq.heappush(q, -arr[0])
for i in range(1, n):
    tmp = heapq.heappop(q)
    tmp *= -1
    ans += tmp
    heapq.heappush(q, -arr[i])
    heapq.heappush(q, -arr[i])
print(ans)


Measured memory_bytes: 31632
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	LLI x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<LLI> p(a), q(b), r(c);

	vector<pair<LLI, char>> v;

	REP(i, a)
	{
		int tmp;
		cin >> tmp;
		v.push_back(make_pair(tmp, 2));
	}

	REP(i, b)
	{
		int tmp;
		cin >> tmp;
		v.push_back(make_pair(tmp, 1));
	}

	REP(i, c)
	{
		int tmp;
		cin >> tmp;
		v.push_back(make_pair(tmp, 0));
	}

	RSORT(v);


	LLI sum = 0;
	LLI ca = 0;
	LLI cb = 0;
	LLI cc = 0;
	int i = 0;
	while (i < v.size())
	{
		if (v[i].second == 0)
		{
			if (x - ca + y - cb < cc)
			{
				break;
			}
			cc++;
		}
		if (v[i].second == 1)
		{
			if (y <= cb)
			{
				i++;
				continue;
			}
			cb++;
		}
		if (v[i].second == 2)
		{
			if (x <= ca)
			{
				i++;
				continue;
			}
			ca++;
		}
		if (x - ca + y - cb < cc)
		{
			break;
		}

		sum += v[i].first;
		i++;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 12908
def witness(a, n, t, u):
    x = pow(a, u, n)  # x0 = a^u mod nを計算
    y = x

    for _ in range(0, t):
        y = (x * x) % n

        # 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
        if y == 1 and x != 1 and x != (n - 1):
            return True
        x = y
    return y != 1

def is_probably_prime(n, witnesses):
    t = 1
    u = n >> 1
    while u & 1 == 0:
        t = t + 1
        u >>= 1
    assert(2**t * u == n - 1)

    for a in witnesses:
        if a < n and witness(a, n, t, u):
            return False
    return True

def is_definitely_prime(n):
    if ((not (n & 1)) and n != 2) or (n < 2) or ((n % 3 == 0) and (n != 3)):
        return False
    elif n <= 3:
        return True
    else:
        return is_probably_prime(n, [2, 7, 61])

n = int(input())
answer = 0
for _ in range(0, n):
    m = int(input())
    if is_definitely_prime(m):
        answer = answer + 1
print(answer)


Measured memory_bytes: 5624
s = input()
a = int(s[:2])
b = int(s[2:])

if a >= 1 and a <= 12 and b >= 1 and b <= 12:
    print("AMBIGUOUS")
elif a >= 1 and a <= 12:
    print("MMYY")
elif b >= 1 and b <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
LL a[N];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		cin>>a[i];
	LL ans = 0;
	for(int i = 2; i <= n; i++)
	{
		if(a[i] < a[i - 1])
		{
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		} 
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>
int main()
{
//int p;
	double r, x, y; 

	scanf("%lf", &r);
    x = r * r * 3.141592653589;
	y = r * 2 * 3.141592653589;
	printf("%f %f\n", x, y);

	//scanf("%d", &p);
	return 0;

}

Measured memory_bytes: 648
import java.util.*;

class Main{

    int n,m,k;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            k = sc.nextInt();
            if(n==0 && m==0 && k==0) break;

            int[][] dp = new int[n][n*m+1];

            for(int i=1; i<=m; i++){
                dp[0][i] = 1;
            }

            for(int i=1; i<n; i++){
                for(int j=1; j<=n*m; j++){
                    for(int l=1; l<=m; l++){
                        dp[i][j] += dp[i-1][Math.max(j-l,0)];
                    }
                }
            }

            double ans = 0.0;
            for(int i=0; i<=n*m; i++){
                ans += (double)dp[n-1][i]/Math.pow(m,n)*Math.max(i-k,1);
            }

            System.out.println(ans);
        }
    }

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

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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

int a[105];
int dp[105][nv];

int inline solve() {
    //input;//,output;
    //fix;
    fast_io;
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    dp[0][k] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= k; ++j) {
            dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
        }
        for (int j = 0; j <= k; ++j) {
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][min(k, j + a[i])]) % mod;
            if(j) dp[i + 1][j] = (dp[i + 1][j] - dp[i][j - 1] + mod) % mod;
        }
    }
    cout << dp[n][0];
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
6
2 1 6 3 4 5
2 1 3 4 5 6
6 0
1 7 8 2 4 6
 * */

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

int main (void){
int c;
cin >> c;
int dig[10];
  
int v=0;
bool f1;
bool f2;
bool f3;
bool vg=false;
for (long i0=0;i0<4;i0++){ if(i0==0&(vg==true))continue; vg|=i0>0;
for (long i1=0;i1<4;i1++){ if(i1==0&(vg==true))continue; vg|=i1>0;
for (long i2=0;i2<4;i2++){ if(i2==0&(vg==true))continue; vg|=i2>0;
for (long i3=0;i3<4;i3++){ if(i3==0&(vg==true))continue; vg|=i3>0;
for (long i4=0;i4<4;i4++){ if(i4==0&(vg==true))continue; vg|=i4>0;
for (long i5=0;i5<4;i5++){ if(i5==0&(vg==true))continue; vg|=i5>0;
for (long i6=0;i6<4;i6++){ if(i6==0&(vg==true))continue; vg|=i6>0;
for (long i7=0;i7<4;i7++){ if(i7==0&(vg==true))continue; vg|=i7>0;
for (long i8=0;i8<4;i8++){ if(i8==0&(vg==true))continue; vg|=i8>0;
for (long i9=0;i9<4;i9++){ if(i9==0&(vg==true))continue; vg|=i9>0;
  f1=(bool)((i0==1)|(i1==1)|(i2==1)|(i3==1)|(i4==1)|(i5==1)|(i6==1)|(i7==1)|(i8==1)|(i9==1));
  f2=(bool)((i0==2)|(i1==2)|(i2==2)|(i3==2)|(i4==2)|(i5==2)|(i6==2)|(i7==2)|(i8==2)|(i9==2));
  f3=(bool)((i0==3)|(i1==3)|(i2==3)|(i3==3)|(i4==3)|(i5==3)|(i6==3)|(i7==3)|(i8==3)|(i9==3));
    long rr = ((i9==0?0:1)+2*i9)*1+
    ((i8==0?0:1)+2*i8)*10+
    ((i7==0?0:1)+2*i7)*100+
    ((i6==0?0:1)+2*i6)*1000+
    ((i5==0?0:1)+2*i5)*10000+
    ((i4==0?0:1)+2*i4)*100000+
    ((i3==0?0:1)+2*i3)*1000000+
    ((i2==0?0:1)+2*i2)*10000000+
    ((i1==0?0:1)+2*i1)*100000000+
    ((i0==0?0:1)+2*i0)*1000000000;
  if( rr <=c ){if(f1&f2&f3)v++; }    
    if(rr>0 )continue;
    if(f1&f2&f3)cout << ((i9==0?0:1)+2*i9)*1+
    ((i8==0?0:1)+2*i8)*10+
    ((i7==0?0:1)+2*i7)*100+
    ((i6==0?0:1)+2*i6)*1000+
    ((i5==0?0:1)+2*i5)*10000+
    ((i4==0?0:1)+2*i4)*100000+
    ((i3==0?0:1)+2*i3)*1000000+
    ((i2==0?0:1)+2*i2)*10000000+
    ((i1==0?0:1)+2*i1)*100000000+
    ((i0==0?0:1)+2*i0)*1000000000 << endl;
                    
}
}
}
}
}
}
}
}
}
}
cout << v << endl;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll w, h;

    bool is_shifted;
    while (cin >> h >> w)
    {
        if (w == 0 && h == 0)
            break;

        for (ll j=0; j<h; j++)
        {
            is_shifted = (j % 2) ? false : true;

            char letter = (is_shifted) ? '#' : '.';
            for (ll i=0; i<w; i++)
            {
                letter = (is_shifted) ? '#' : '.';
                cout << letter;
                is_shifted = !is_shifted;
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
int divi[1001];

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

  rep(i,1001){
    divi[i]=0;
  }

  rep(i,n){
    int k=i+1;
    rep(j,k){
      if(j==0) continue;
      int d=j+1;
      while(k%d==0){
        divi[d]++;
        k/=d;
      }
    }
  }

  ll ans=1;
  REP(i,1,1001){
    ans*=divi[i]+1;
    ans%=MOD;
  }

  prt(ans);

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int N,K;
  char str[100];
  scanf("%d %d",&N,&K);
  scanf("%s",str);
  if( str[K-1] =='A')
    str[K-1] = 'a';
  if( str[K-1] =='B')
    str[K-1] = 'b'; 
  if( str[K-1] =='C')
    str[K-1] = 'c'; 
  printf("%s\n",str);
  return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

//abc159 B

int main(void)
{
  char S[101];
  int N;
  int i = 0;
  int j = 0;
  bool flag = true;
  scanf("%s", &S);
  N = strlen(S)-1;
  if (N <= 5) {
    if (N == 2) {
      if (S[0] == S[2]) {
        printf("Yes\n");
      }else printf("No\n" );
      return 0;
    }else{
      if (S[0] == S[1] && S[3] == S[4] && S[0] == S[4] && S[1] == S[3] ) {
        printf("Yes\n" );
      }else printf("No\n");
      return 0;
    }

  }
  int M = N;
  i = 0;
  while (i != M && flag == true) {
    if (S[i] == S[M] ) {
      i++;
      M--;
    }else {
      flag = false;
      break;
    }
    if (i + 1 == M) {
      if (S[i] != S[M] ) {
        flag = false;
      }
      break;
    }
  }
  i = 0;
  j = (N-1)/2;
  int h = (N+3)/2;
  while (i != j && flag == true) {
    if (S[i] == S[j] && S[i+h] == S[N]) {
      i++;
      j--;
      N--;
    }else {
      flag = false;
      break;
    }
    if (i + 1 == j) {
      if (S[i] != S[j] && S[i+h] != S[N]) {
        flag = false;
      }
      break;
    }
  }

  if (flag == true) {
    printf("Yes\n" );
  }else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main (){
  int a,b,c,x,i=0;
  scanf("%d %d %d",&a,&b,&c); 
  for (x=a;x<=b;x++){
    if ( c%x==0 ){
      i++;
    }
  }
  printf("%d\n",i);
  return 0;
}
  

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

#define REP(i,a) for(long i=0;i<(a);++i)
typedef long long int LL;
typedef std::vector<LL> VLL;

int N;
VLL A;

int main() {
    std::cin >> N;
    A.resize(N);
    REP(i, N) {
        std::cin >> A[i];
    }

    LL ans1 = 0, ans2 = 0;

    LL sum = 0, dist = -1;
    REP(i, N) {
        dist *= -1;
        sum += A[i];
        if(sum * dist <= 0) {
            ans1 += std::abs(sum - dist);
            sum = dist;
        }
    }

	sum = 0, dist = 1;
    REP(i, N) {
        dist *= -1;
        sum += A[i];
        if(sum * dist <= 0) {
            ans2 += std::abs(sum - dist);
            sum = dist;
        }
    }
    std::cout << std::min(ans1, ans2) << std::endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    ll xa = 0;
    ll bx = 0;
    ll bxa = 0;
    ll ab = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        ll l = s.length();
        if (s[0] == 'B' && s[l - 1] == 'A')
            bxa++;
        else if (s[l - 1] == 'A')
            xa++;
        else if (s[0] == 'B')
            bx++;
        for (int j = 0; j <= l - 2; j++)
        {
            string tmp;
            tmp = s.substr(j, 2);
            if (tmp == "AB")
                ab++;
        }
    }
    if (xa + bx == 0&&bxa!=0)
        cout << ab + bxa - 1 << endl;
    else
        cout << ab + min(xa, bx)+bxa << endl;
}

Measured memory_bytes: 3612
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] array = sc.intarr;

            int ans = array[2] - (array[0] - array[1]);

            if(ans < 0)
            {
                wr.wri("0");
                return;
            }
            wr.wri(ans);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};
 
// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ---------------------------------------------------------------------------

int main(){
  string S;
  cin >> S;
  if(S == string(3,'A') || S == string(3,'B')){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  } 
  return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    int pre = 0, now = 0;
    int ans = 0;
    for (int i=0; i<n; i++) {
        cin >> now;
        if (now == pre) {
            ans++;
            pre = -1;
        }
        else {
            pre = now;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        int[][] dp = new int[s.length+1][t.length+1];

        for (int i=1; i<=s.length; i++) {
            for (int j=1; j<=t.length; j++) {
                if (s[i-1] == t[j-1]) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                } else {
                    dp[i][j] = (dp[i][j-1] < dp[i-1][j]) ?
                            dp[i-1][j] : dp[i][j-1];
                }
            }
        }

//        System.out.println(dp[s.length][t.length]);

        StringBuilder sb = new StringBuilder();

        int i = s.length - 1;
        int j = t.length - 1;
        while (0 <= i && 0 <= j) {
            if (s[i] == t[j]) {
                sb.append(s[i]);
                i--;
                j--;
            } else {
                if (dp[i][j+1] < dp[i+1][j]) {
                    j--;
                } else {
                    i--;
                }
            }
        }

        System.out.println(sb.reverse().toString());
    }
}



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



int main(){
    int N;
    cin >> N;
    
    vector<long double> A(N),B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    
    //奇数のとき
    if(N%2 == 1){
        long double med_min, med_max;
        ll ans;
        med_min = A[(N-1)/2];
        med_max = B[(N-1)/2];
        ans = med_max - med_min + 1;
        cout << ans << endl;
    }
    
    //偶数のとき
    if(N%2 == 0){
        long double med_min, med_max;
        ll ans;
        med_min = (A[N/2 -1] + A[N/2])/2;
        med_max = (B[N/2 -1] + B[N/2])/2;
        ans = (med_max - med_min)*2 + 1;
        cout << ans << endl;
    }
}


Measured memory_bytes: 9564
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
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; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
int main()
{
    int N;
    cin >> N;
    VLL a(N);
    rep(i,N){
        cin >> a[i];
    }
    ll sum=0;
    rep(i,N){
        sum+=a[i]-1;
    }
    cout << sum << endl;
}

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

int main(){
  string s;
  cin >> s;
  int counter = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == s[i + 1]){
      counter++;
    }
  }
  if(counter >= 2 && s[1] == s[2]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
function solve(S)
  ret = S[end]

  for i in 1:length(S)
    here = i - S[i] + S[end] - S[i]
    if here < ret
      ret = here
    end
  end
  ret
end
readline()
S = cumsum(collect(strip(readline())) .== '.')
println(solve(S))

Measured memory_bytes: 173084
import sys
from itertools import groupby
from copy import deepcopy

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def do_drop(H, W, G):
    for j in range(W):
        for i in range(H - 1):
            for k in range(H - 1, i, -1):
                if G[k][j] == 0 and G[k - 1][j] != 0:
                    G[k][j], G[k - 1][j] = G[k - 1][j], G[k][j]


def main():
    H, W, K = map(int, readline().split())
    G_base = [list(map(int, readline().strip())) for _ in range(H)]

    ans = 0
    for i in range(H):
        for j in range(W):
            G = deepcopy(G_base)
            G[i][j] = 0
            do_drop(H, W, G)

            power = 1
            score = 0
            while True:
                finished = True
                total = 0
                for row in G:
                    idx = 0
                    for k, g in groupby(row):
                        l = len(list(g))
                        if k > 0 and l >= K:
                            row[idx : idx + l] = [0] * l
                            total += k * l
                            finished = False
                        idx += l

                if finished:
                    break

                score += power * total
                power *= 2
                do_drop(H, W, G)

            if ans < score:
                ans = score

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 56540
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)
#define MAX ((ull)(1e9)+1)

int main(){
	int n;
	cin >> n;
	double ans=0.0;
	for(int i=0; i<n; i++){
		double d;
		string s;
		cin >> d >> s;
		if(s=="JPY"){
			ans+=d;
		}else{
			ans+=d*380000.0;
		}
	}
	printf("%.6f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}

int main(){
  ll h, w;
  cin >> h >> w;

  if(h == 1 || w == 1) cout << 1 << endl;
  else cout << (long)ceil(h*w/2.0) << endl;

  return 0;
}

Measured memory_bytes: 256
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for i in range(q)]
d=list(itertools.combinations_with_replacement(list(range(1,m+1)), n))
ans=0
count=0
for i in range(len(d)):
  for j in range(q):
    if abcd[j][2]==d[i][abcd[j][1]-1]-d[i][abcd[j][0]-1]:
      count+=abcd[j][3]
  if ans<count:
    ans=count
  count=0
print(ans)
  

Measured memory_bytes: 21616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    int ans = 1e9;

    for(int i = 1; i <= N; i++) {
        int S1 = 0;
        int S2 = 0;
        for(int j = 0; j < N; j++) {
            if(j <= i) {
                S1 += v[j];
            } else {
                S2 += v[j];
            }
        }
        ans = min(abs(S1 - S2), ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

int main(void)
{
    int h,a;
    cin >>h >>a;

    if(h % a){
        printf("%d\n", h / a + 1);
    }else{
        printf("%d\n", h / a);
    }

    return 0;
}

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


struct ans
{
    int y1; 
    int x1; 
    int y2; 
    int x2;
};


int main()
{
    int h,w;
    std::cin >> h >> w;
    std::vector<std::vector<int>> map(h,std::vector<int>(w)), test(h,std::vector<int>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            std::cin >> map[i][j];
        }
    }
    std::vector<ans> Ans;
    

    int cur_x = 0, cur_y = 0, next_x, next_y;

    for(int k = 0; k < w * h - 1; k++){
        if(k % (w * 2) < w && cur_x < w - 1){
            next_x = cur_x + 1;
            next_y = cur_y;
        }else if(k % (w * 2) < w && cur_x == w - 1){
            next_x = cur_x;
            next_y = cur_y + 1;
        }else if(k % (w * 2) >= w && cur_x != 0){
            next_x = cur_x - 1;
            next_y = cur_y;
        }else if(k % (w * 2) >= w && cur_x == 0){
            next_x = cur_x;
            next_y = cur_y + 1;
        }
        /*
        if(map[cur_y][cur_x] & 1 && !flag){
            Ans.push_back({cur_y,cur_x,next_y,next_x});
            map[cur_y][cur_x]--;
            map[next_y][next_x]++;
            flag = true;
        }else if(map[cur_y][cur_x] % 2 == 0 && flag){
            Ans.push_back({cur_y,cur_x,next_y,next_x});
            map[cur_y][cur_x]--;
            map[next_y][next_x]++;
        }else if(map[cur_y][cur_x] & 1 && flag){
            flag = false;
        }
        */
       if(map[cur_y][cur_x] & 1){
           Ans.push_back({cur_y,cur_x,next_y,next_x});
           map[cur_y][cur_x]--;
           map[next_y][next_x]++;
       }
        test[cur_y][cur_x] = k;
        cur_x = next_x;
        cur_y = next_y;
    }
    std::cout << Ans.size() << std::endl;
    for(int i = 0; i < (int)Ans.size(); i++){
        std::cout << Ans[i].y1 + 1 << " " << Ans[i].x1 + 1<< " " <<Ans[i].y2 + 1<< " " << Ans[i].x2 + 1<< std::endl; 
    }
}

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


int main()
{
	int n, k,x[100000],sum=10000000000000;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (i >= k-1){
			if (x[i - k + 1] < 0 && x[i]>0) {
				if (x[i - k + 1] + x[i] >= 0)sum = min(sum, x[i] - 2 * x[i - k + 1]);
				else sum = min(sum, 2 * x[i] - x[i - k + 1]);
			}
			else if(0<=x[i-k+1])sum = min(sum, x[i]);
			else if (x[i] <= 0)sum = min(sum, -x[i - k + 1]);
			
		}
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main () {
  char xi;
  cin >> xi;
  if(xi=='a'||xi=='b'||xi=='c'||xi=='d'||xi=='e'||xi=='f'||xi=='g'||xi=='h'||xi=='i'||xi=='j'||xi=='k'||xi=='l'||xi=='m'||xi=='n'||xi=='o'||xi=='p'||xi=='q'||xi=='r'||xi=='s'||xi=='t'||xi=='u'||xi=='v'||xi=='w'||xi=='x'||xi=='y'||xi=='z') {
    cout << 'a' << endl;
  }
  else {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 3620
#include <stdio.h>

int A[500000],count=0;

void merge(int *A, int left, int mid, int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  
  int L[n1], R[n2];
  
  for (i=0; i<n1; i++)
    L[i] = A[left + i];
  for (i=0; i<n2; i++)
    R[i] = A[mid + i];
  L[n1] = 1000000001;
  R[n2] = 1000000001;
  i = 0;
  j = 0;
  for (k=left; k<right; k++){
    if (L[i] <= R[j]){
      count++;
      A[k] = L[i];
      i = i + 1;
    }
    else {
      count++;
      A[k] = R[j];
      j = j + 1;
    }
  }
}


void mergeSort(int *A, int left, int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int i, n;

  scanf("%d",&n);
  for(i=0; i<n; i++)
    scanf("%d",&A[i]);
  mergeSort(A,0,n);

  for(i=0; i<n-1; i++)
    printf("%d ",A[i]);
  printf("%d\n%d\n",A[i],count);

  return 0;
}
  

  
  



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define rep(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define repr(i, n) for(int i = n;i >= 0;--i)
#define reparr(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
	return 0;
}

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


#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define endl '\n'
#define PI acos(-1.0)
#define CASE(n) cout << "Case " << n << ": "
#define CASE_(n) cout << "Case " << n << endl
#define FIXED(n) cout << fixed << setprecision(n)
#define MOD 1000000007

inline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); }
inline long long modMul(long long a, long long b) { normal(a), normal(b); return (a*b)%MOD; }
inline long long modAdd(long long a, long long b) { normal(a), normal(b); return (a+b)%MOD; }
inline long long modSub(long long a, long long b) { normal(a), normal(b); a -= b; normal(a); return a; }
inline long long modPow(long long b, long long p) { long long r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline long long modInverse(long long a) { return modPow(a, MOD-2); }
inline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }



int main()
{
    O_O;
#ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
#endif
    long long t=1;
    //cin >> t;
    long long T = t;
    while(t--)
    {
        //write your code here
        int n;
        cin >> n;
        vector<pair<int,int>>arr;
        for(int i=0;i<n;i++)	
        {
        	int x;
        	cin >> x;
        	arr.push_back({x,i+1});
        }
        sort(arr.begin(), arr.end());
        for(int i=0;i<arr.size();i++)
        {
        	cout << arr[i].second << ' ';
        }
        cout << endl;

    }
    return 0;
}




Measured memory_bytes: 4208
#include<iostream>
//#include<cstring>
#include<cmath>
//#include<cstdio>
//#include<algorithm>
using namespace std;

long long int n;
int tmp,len=1; 

int main(){
	cin>>n;
	for(int i=sqrt(n); i>=1; i--){
		if(n%i==0){
			tmp=n/i;
			while(tmp>=10){
				tmp=tmp/10;
				len++;
			}
			cout<<len<<endl;
			return 0;
		}
	}
}    

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

int main() {
  int N, K, sum=0;
  cin >> N >> K;
  
  rep(i, N) {
    int x;
    cin >> x;
    if (K / 2 < x) { sum += (K - x) * 2; }
    else { sum += x * 2; }
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace ABC152E
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            BigInteger[] A = ReadLong();

            BigInteger mod = 1000000007;
            BigInteger lcm = 1;
            //lcm = (A.Aggregate(Calc.Lcm) % mod);
            for (int i = 0; i < N; i++)
            {
                lcm = Calc.Lcm(A[i], lcm);
            }
            lcm %= mod;

            BigInteger sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += (lcm * Calc.ModPow(A[i], mod - 2, mod)) % mod;
                sum %= mod;
            }

            Console.WriteLine(sum);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static BigInteger[] ReadLong()
        {
            BigInteger[] ret = Console.ReadLine().Split().Select(BigInteger.Parse).ToArray();
            return ret;
        }
    }

    class Calc
    {
        // 最小公倍数
        public static BigInteger Lcm(BigInteger a, BigInteger b)
        {
            //return a / Gcd(a, b) * b;
            return a / (BigInteger)BigInteger.GreatestCommonDivisor(a, b) * b;
        }

        // ユークリッドの互除法 
        public static BigInteger Gcd(BigInteger a, BigInteger b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        /// <summary>
        /// a^n (mod p)
        /// nが非常に大きい時に有効
        /// </summary>
        /// <param name="a"></param>
        /// <param name="n"></param>
        /// <param name="mod"></param>
        /// <returns></returns>
        public static BigInteger ModPow(BigInteger a, BigInteger n, BigInteger p)
        {
            if (n == 1) return a % p;
            if (n % 2 == 1) return (a * ModPow(a, n - 1, p)) % p;

            BigInteger t = ModPow(a, n / 2, p);
            return (t * t) % p;
        }

        /// <summary>
        /// 組み合わせ個数
        /// </summary>
        /// <param name="n"></param>
        /// <param name="k"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static BigInteger nCk(BigInteger n, BigInteger k, BigInteger p)
        {
            BigInteger ans = 1;
            for (BigInteger i = n; i > n - k; i--)
            {
                ans = (ans * i) % p;
            }

            for (BigInteger i = 1; i <= k; i++)
            {
                ans = (ans * ModPow(i, p - 2, p)) % p;
            }

            return ans;
        }
    }
}


Measured memory_bytes: 36944
#include<cstdio>

int main(void)
{
	int a,b;
	scanf("%d %d", &a,&b);
	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 2556
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int t;
	for (scanf("%d",&t);t--;)
	{
		long long a,b,c,d;
		scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
		if (a<b) puts("No");
		else
		{
			a%=b;
			long long g=__gcd(b,d);
			if (a%g+d<b) puts("No");
			else
			{
				if (a%g==0)
				{
					if (c<b-g) puts("No");
					else puts("Yes");
				}
				else
				{
					long long lim=a+(b-a)/g*g;
					if (c<lim) puts("No");
					else puts("Yes");
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, k;
    sc(n) sc(k)
    ll ans = k;
    REP(i, n-1){
        ans *= k - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
#n = ip()                                     #入力整数1つ
s,c= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
ans = 0
if c > s:
    ans+=s
    c-=s*2
    ans+=(c//4)
else:
    ans = c//2
print(ans)


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

int main(){
  int N, Y;
  cin >> N >> Y;
  for(int i=0; i<=N; i++){
    for(int j=0; j<=N-i; j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        cout << i << " " << j << " " << N-i-j << endl;
        goto finish;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;

  finish: N=0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;


vector<int> v[1010];
int a[1010];
pint dfs(int x){
    if(v[x].empty())return {0,a[x]};
    bitset<5050> b=1;
    int sum=0;
    for(auto to:v[x]){
        pint p=dfs(to);
        if(p.first==-1)return {-1,-1};
        b=(b<<p.first|b<<p.second);
        sum+=p.first+p.second;
    }
    for(int i=a[x];i>=0;i--){
        if(b[i])return {a[x],sum-i};
    }
    return {-1,-1};
}

int main(){
    int n;cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    ll ans=0;
    while(1){
        sort(a,a+n);
        reverse(a,a+n);
        if(a[0]<n)break;
        ll pos=a[0]/n;
        ans+=pos;
        a[0]-=pos*n;
        rep(i,n-1)a[i+1]+=pos;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var H, W int
	for {
		fmt.Scan(&H)
		fmt.Scan(&W)

		if H == 0 && W == 0 {
			break
		}
		for h := 0; h < H; h++ {
			if h == 0 || h == H-1 {
				for w := 0; w < W; w++ {
					fmt.Print("#")
				}
				fmt.Println()
				continue
			}
			fmt.Print("#")
			for w := 1; w < W-1; w++ {
				fmt.Print(".")
			}
			fmt.Println("#")
		}
		fmt.Println()
	}

}



Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
const int N=2*1e5+1;
string s;
int i,p[26][N],c[26],odd,f[N],n,FT[N];
int find(int i){return i?FT[i]+find(i-(i&-i)):0;}
void add(int i){while(i<=n)FT[i]++,i+=i&-i;}
int main(){
	cin>>s;n=s.size();
	for(i=0;s[i];i++)
		p[s[i]-'a'][c[s[i]-'a']++]=i;
	for(i=0;i<26;i++)if(c[i]&1)odd++;
	if(odd>1)return puts("-1"),0;
	for(i=0;i<26;i++)
		for(int j=0;j<c[i];j++)
			f[p[i][c[i]-1-j]]=p[i][j]+1;
	long long ans=0;
	for(int i=n-1;~i;i--){
		ans+=(n-1-i)-find(f[i]);
		add(f[i]);
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 20612
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++) cin >> l[i];

    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());

    int ans = 0;
    for (int i = 0; i < k; i++) ans += l[i];

    cout << ans << endl;

    return 0;
}








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

using namespace std;

const int INF = 10000000;

struct edge {
    int to, cap, rev;
    edge(int t, int c, int r) : to(t), cap(c), rev(r) {};
};

const int MAX_V = 500 + 500 + 2;
vector<vector<edge> > G(MAX_V, vector<edge>());
bool used[MAX_V];

void add_edge(int from, int to, int cap)
{
    G[from].push_back(edge(to, cap, G[to].size()));
    G[to].push_back(edge(from, 0, G[from].size() - 1));
}

int dfs(int v, int t, int f)
{
    if (v == t)
        return f;

    used[v] = true;

    for (int i = 0; i < G[v].size(); ++i) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t)
{
    int f = 0;

    for (;;) {
        memset(used, 0, sizeof(used));
        int d = dfs(s, t, INF);
        if (d == 0)
            break;
        f += d;
    }

    return f;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);

    while (b != 0) {
        a = a % b;
        swap(a, b);
    }

    return a;
}

int b[500], r[500];

#define sv 0
#define bv(i) (1 + (i))
#define rv(i) (1 + m + (i))
#define tv (1 + m + n)

int main()
{
    for (;;) {
        int m, n;
        scanf("%d %d", &m, &n);
        if (m ==0 && n == 0)
            break;

        for (int i = 0; i < MAX_V; ++i)
            G[i].clear();

        for (int i = 0; i < m; ++i) {
            scanf("%d", &b[i]);
            add_edge(sv, bv(i), 1);
        }
        for (int i = 0; i < n; ++i) {
            scanf("%d", &r[i]);
            add_edge(rv(i), tv, 1);
        }

        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < n; ++j) {
                if (gcd(b[i], r[j]) != 1) {
                    add_edge(bv(i), rv(j), 1);
                }
            }
        }

        /*
        for (int i = 0; i <= tv; ++i) {
            printf("%d to:\n", i);
            for (int j = 0; j < G[i].size(); ++j) {
                printf("%2d ", G[i][j].to);
            }
            printf("\n");
        }
        */

        printf("%d\n", max_flow(sv, tv));
    }

    return 0;
}

Measured memory_bytes: 7432
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main() {
	string S;
	cin >> S;
	ll K;
	cin >> K;
	for (ll i = 0; i < K; i++) {
		if (S[i] != '1'){
		cout << S[i] << endl;
      	return 0;
        }
	}
  	cout<<1<<endl;
  	return 0;
}










Measured memory_bytes: 256