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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string s,t;
  cin >> s >> t;
  
  int m = s.length();
  int n = t.length();
  
  int dp[m+1][n+1] = {};
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(s[i]==t[j]){
        dp[i+1][j+1] = dp[i][j]+1;
      }
      else{
        dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }
  int i = m;
  int j = n;
  string ans = "";
  while(i>0&&j>0){
    if(dp[i][j]==dp[i-1][j]){
      i--;
    }
    else if(dp[i][j]==dp[i][j-1]){
      j--;
    }
    else{
      ans.push_back(s[i-1]);
      i--;j--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 38760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
    int N, M, ans;
    cin >> N >> M;
    ans = (N + M) * (N + M - 1) / 2 - N * M;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    char c[h][w];
    REP(i, 0, h) REP(j, 0, w) {
        cin >> c[i][j];
    }
    REP(i, 0, 2 * h) {
        REP(j, 0, w) {
            cout << c[i/2][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
num = input()
#direction = input()
ar_direction = list(input())

res = []

west = False
last_val = len([d for d in ar_direction[1:] if d == 'E'])


for i, d in enumerate(ar_direction):
  current_res = last_val
  if west:
    current_res += 1
  
  west = d == 'W'

  if not i == 0 and not west:
    current_res -= 1

  res.append(current_res)
  last_val = current_res

print(min(res))

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

int main(){
  int l, r;
  cin >> l >> r;
  int ans = 0;
  for(int a = 1; a < 10; a++){
    for(int b = 0; b < 10; b++){
      for(int c = 0; c < 10; c++){
        int x = 10001 * a + 1010 * b + 100 * c;
        if(x >= l && x <= r){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static public void main(String args[]){
  	Scanner scan = new Scanner(System.in);
  	
  	int x = scan.nextInt();
  	
  	int result = 0;
  	
  	result = (int)Math.pow(x,3);
  	System.out.println(result);
  }
}

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

int main () {
    int x; std::cin >> x;


    int base = std::sqrt(x);
    int ans = 1;
    for(int i = 2; i <= base; i++) {
        int j = 1;
        int max;
        while(1) {
            if(std::pow(i, j) > x) {
                max = std::pow(i, j - 1);
                break;
            }
            j++;
        }

        ans = std::max(ans, max);
    }

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

Measured memory_bytes: 3968
Q,H,S,D = map(int,input().split())
N = int(input())

S = min(S,2*H,4*Q)
if N != 1:
  if 2*S <= D:
    print(S*N)
  else:
    print(D*(N//2) +(N%2)*S)
else:
  print(S)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

long long lcm(long long a, long long b);

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

	vector<int> x(n);
	cin >> x[0];
	if (x[0] % 2 == 1) {
		cout << 0 << endl;

		return 0;
	}
	int t = 0;
	while (x[0] % 2 == 0) {
		t++;
		x[0] /= 2;
	}

	int tmp = pow(2, t);
	for (int i = 1; i < n; i++) {
		cin >> x[i];

		if ((x[i] / tmp) % 2 == 1) {
			x[i] /= tmp;
		}
		else {
			cout << 0 << endl;

			return 0;
		}
	}
	m /= pow(2, t - 1);

	long long l = 1;
	for (int i = 0; i < n; i++) {
		l = lcm(x[i], l);
		
		if (l > m) {
			cout << 0 << endl;
			return 0;
		}
	}

	m /= l;
	cout << (m + 1) / 2 << endl;


	return 0;
}

long long lcm(long long a, long long b)
{
	if (a < b) {
		long long t = a;
		a = b;
		b = t;
	}

	long long aa = a;
	long long bb = b;
	long long r = a % bb;

	while (r != 0) {
		aa = bb;
		bb = r;
		r = aa % bb;
	}

	return b * a / bb;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 14:58:59 2019

@author: Yamazaki Kenichi
"""

S = input()
T = input()
N = len(S)
flg = True
x ={}
for i in range(N):
    try:
        if x[S[i]] == T[i]:
            continue
        else:
            flg = False
    except:
        x[S[i]] = T[i]
x ={}
for i in range(N):
    try:
        if x[T[i]] == S[i]:
            continue
        else:
            flg = False
    except:
        x[T[i]] = S[i]
if flg:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3632
n,m = map(int,input().split())
if n%2 == 1:
  for i in range(m):
    print((n-1)//2-i,(n+1)//2+i)
else:
  for i in range(min(m,(n//2)//2)):
    print(n//2-i,1+i)
  if m > (n//2)//2:
    for i in range(m-(n//2)//2):
      print(n-i,n//2+2+i)

Measured memory_bytes: 9272
#include<iostream>
#include<cmath>
 
using namespace std;
 
int digits(long long n)
{
	int r = 0;
 
	while(n > 0)
	{
		n /= 10;
		r++;
	}
 
	return r;
}
 
int func(long long a,long long b)
{
	return max(digits(a),digits(b));
}
 
int main()
{
	long long N;
	int ans = 100;
 
 
	cin >> N;
 
	for(long long i=1;i<=(long long)(N/i);i++)
	{
		if(N%i==0)
		{
			ans = min(func(i,N/i),ans);
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int MAX=1e3+5;
int main(int argc, char *argv[])
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	printf("%d\n",min(a,b)+min(c,d));
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll power(ll k, ll n, int M) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}



int main() {
  int N, A[SIZE];
  map<int,int> mm;

  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    scanf("%d", A+i);

    int tmp = A[i];
    for (int j=2; j*j<=tmp; j++) {
      if (tmp % j) continue;

      int counter = 0;
      while(tmp % j == 0) {
        counter++;
        tmp /= j;
      }

      mm[j] = max(mm[j], counter);
    }

    if (tmp)
      mm[tmp] = max(mm[tmp], 1);
  }

  ll lcm = 1;

  for (auto p : mm) {
    lcm = lcm * power(p.first, p.second, mod) % mod;
  }

  ll ans = 0;

  for (int i=0; i<N; i++) {
    ans += lcm * power(A[i], mod-2, mod) % mod;
  }

  cout << ans % mod << endl;


  return 0;
}


Measured memory_bytes: 768
import Data.Bits
import Data.Array
main = do
  n <- read  <$> getLine
  x <- getLine
  let 
      p = length $ filter (=='1') x
      pow2_0 = reverse $ take n $ iterate (\t -> (2*t)  `mod` (p+1)) 1
      pow2_1 = reverse $ take n $ iterate (\t -> (2*t)  `mod` (p-1)) 1
      r0 = sum $ zipWith (\c m -> if c == '1' then m else 0) x pow2_0
      r1 = sum $ zipWith (\c m -> if c == '1' then m else 0) x pow2_1
      xs = zipWith3 (\c m0 m1 -> if c == '1' && p /= 1 then (r1 - m1) `mod` (p-1) else if c == '1' && p == 1 then -1 else (r0 + m0) `mod` (p+1)) x pow2_0 pow2_1
      ans = fmap (print . f) xs
  sequence ans

f :: Int -> Int
f n
  | n == -1 = 0
  | n == 0 = 1
  | otherwise = 1 + f n'
  where n' = n `mod` popCount n




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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  map<string, int> D;
  for (int i = 0; i < N; i++) {
    if (D.count(S.at(i))) {
      D.at(S.at(i)) ++;
    }
    else {
      D[S.at(i)] = 1;
    }
  }
  int M = 0;
  for (auto p : D) {
    auto k = p.second;
    M = max(M, k);
  }
  for (auto p : D) {
    auto k = p.second;
    auto l = p.first;
    if (k == M) {
      cout << l << endl;
    }
  }
}


Measured memory_bytes: 26752
use std::io;

fn main() {
    println!("{}", yes_no(read_string().starts_with("YAKI")))
}

fn read_string() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.pop().unwrap();
    input
}

fn yes_no(flag: bool) -> String {
    match flag {
        true => "Yes".to_owned(),
        false => "No".to_owned(),
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n+1-h)*(n+1-w) << endl;
}

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

int main() {
  int n;
  cin >> n;
  if(n%2 == 0) cout << n/2 << endl;
  else cout << n/2+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 * 2;

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	int div = max(h, w);
	cout << (n + div - 1) / div << endl;
}


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

int main() {
	string s, p; cin >> s >> p;
	s += s;
	rep(i, s.size() - p.size() + 1) {
		if (s.substr(i, p.size()) == p) {
			puts("Yes"); return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 3196
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main(){
    char s[20];
    int sum=0,clo=10000000,m=100,i;
    scanf("%s",s);
    for(i=0;i<strlen(s)-2;i++){
        for(int j=i;j<=i+2;j++){
            sum=sum+(s[j]-48)*m;
            m=m/10;
        }
        if(clo>abs(sum-753)){
               clo=abs(sum-753);
            
        }
        sum=0;
        m=100;
        
    }
    if(clo==0){
        printf("0");
    }
    else{
        
        printf("%d",clo);
    }
}


Measured memory_bytes: 128
def binary_search(A, n, B, q):
    cnt = 0
    for i in range(q):
        left = 0
        right = n
        while left < right:
            mid = int((left + right) / 2)
            if A[mid] == B[i]:
                cnt += 1
                break
            elif B[i] < A[mid]:
                right = mid
            else:
                left = mid + 1
    return cnt

n = int(input())
A = list(map(int,input().split()))
q = int(input())
B = list(map(int,input().split()))
print(binary_search(A, n, B, q))


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

using namespace std;

const int maxn = 510;

int n, m;
string s[maxn];
string blue[maxn], red[maxn];


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

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) blue[i] += '.';
    red[i] = blue[i];
  }
  for (int i = 0; i < m; i += 2) {
    for (int j = 0; j < n - 1; j++) blue[i][j] = '#';
  }
  
  for (int i = 1; i < m; i += 2) 
    for (int j = 1; j < n; j++) red[i][j] = '#';
  
  for (int i = 0; i < m; i++) {
    blue[i][0] = '#';
    red[i][n-1] = '#';
  }


  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (blue[i][j] == '.' && s[i][j] == '#') cout << '#';
      else cout << blue[i][j];
      // cout << blue[i][j];
    }
    cout << endl;
  }
  cout << endl;

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (red[i][j] == '.' && s[i][j] == '#') cout << '#';
      else cout << red[i][j];
      // cout << red[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1536
main = do
    ss <- getLine
    print $ solve ss 0 0 

solve :: String -> Int -> Int -> Int
solve x b_prev temp_sum
    | x == [] = temp_sum
solve (x:xs) b_prev temp_sum 
    | x == 'B' = solve xs (b_prev+1) temp_sum
    | x == 'W' = solve xs b_prev (temp_sum + b_prev)

Measured memory_bytes: 9468
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CRally {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        vector<int> X(N);
        REP(i,0,N) in >> X[i];
        int minSum = INT_MAX;
        REP(P,1,101) {
            int sum = 0;
            REP(i,0,N) sum+= (X[i] - P) * (X[i] - P);
            if (sum < minSum) {
                minSum = sum;
            }
        }
        out << minSum << endl;
    }
};


signed main() {
    CRally solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    
    int N;
    cin >> N;
    vector<int> L(2 * N);
    for(int i = 0; i < 2 * N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans += min(L[2 * i], L[2 * i + 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1

int main() {
  int N;
  cin >> N;
  int X[N];
  rep(i,N){
    cin >> X[i];
  }
  bool ans = true;
  rep(i,N){
    if(X[i] % 2 == 0){
      if(X[i] % 3 != 0 && X[i] % 5 != 0){
        ans = false;
        break;
      }
    }
  }
  if(ans) cout << "APPROVED" << endl;
  else cout <<"DENIED" << endl;
}
  

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

int main(){
  ll n, ans = 0;
  cin >> n;
  ans = ((n - 1) * n) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
using namespace std;
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 main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max((A+B)-N, 0) << endl;
    return 0;
}

Measured memory_bytes: 764
N = int(input())

def factorize(N):
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res

MOD = 10**9+7
table = [0]*(N+1)
for i in range(2, N+1):
    res = factorize(i)
    for p in res.keys():
        table[p] += res[p]
        table[p] %= MOD

ans = 1
for n in table:
    if n > 0: 
        ans *= (1+n)
        ans %= MOD

print(ans)

Measured memory_bytes: 74136
#include <stdio.h>

int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		if(n==0) break;
		int ans=0;
		int k=5;
		while(n/k>0){
			ans += n/k;
			k *= 5;
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int main(){
	int a,b; char op; cin>>a>>op>>b;
	if(op=='+') cout<<a+b<<endl;
	else cout<<a-b<<endl;
}


Measured memory_bytes: 3604
/*
 * @Author: RBQRBQ
 * @Date: 2020-09-19 15:18:05
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-09-19 16:03:32
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const ll maxn (2000000+10);
const double Pi=acos(-1.0);
#define re register
struct Complex
{
    double x,y;
    Complex (double xx=0,double yy=0){x=xx,y=yy;}
}a[maxn],b[maxn],c[maxn];
Complex operator + (Complex a,Complex b){ return Complex(a.x+b.x,a.y+b.y);}
Complex operator - (Complex a,Complex b){ return Complex(a.x-b.x,a.y-b.y);}
Complex operator * (Complex a,Complex b){ return Complex(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}//不懂的看复数的运算那部分 
ll N,M;
ll l,r[maxn];
ll limit=1;
void fft(Complex *A,ll type)
{
    for(re ll i=0;i<limit;++i) 
        if(i<r[i]) swap(A[i],A[r[i]]);
    for(re ll mid=1;mid<limit;mid<<=1)
    {
        Complex Wn(cos(Pi/mid),type*sin(Pi/mid)); 
        for(ll R=mid<<1,j=0;j<limit;j+=R)
        {
            Complex w(1,0);
            for(re ll k=0;k<mid;++k,w=w*Wn)
            {
                Complex x=A[j+k],y=w*A[j+mid+k];
                A[j+k]=x+y;
                A[j+mid+k]=x-y;
            }
        }
    }
}
/*
***Remember to clear the array ,limit and l!
for(ll i=0;i<=N;i++) read(a[i].x);
for(ll i=0;i<=M;i++) read(b[i].x);
limit=1,l=0;
while(limit<=N+M) limit<<=1,l++;
for(ll i=0;i<limit;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
fft(a,1);
fft(b,1);
for(ll i=0;i<=limit;;i++) c[i]=a[i]*b[i];
fft(c,-1);
for(ll i=0;i<=N+M;i++)
    printf("%d ",(ll)(a[i].x/limit+0.5));
*/
ll A[maxn];
ll mp[maxn];
const ll P(200003);
ll qpow(ll x,ll k,ll p=P) {
    ll ret=1;
    while(k){
        if(k&1)
            ret = ret*(ll)x%p;
        x=x*(ll)x%p;
        k>>=1;
    }
    return ret;
}
int main()
{
    ll n;
    read(n);
    ll cnt=0;
    for(re ll i=1;i<=n;i++)
    {
        ll x;
        read(x);
        if(x==0) continue;
        else A[++cnt]=x;
    }
    n=cnt;
    for(re ll i=0;i<=P-2;i++) mp[qpow(2,i)]=i;
    for(re ll i=1;i<=n;i++) a[mp[A[i]]].x++,b[mp[A[i]]].x++;
    N=M=P; 
    limit=1,l=0;
    while(limit<=N+M) limit<<=1,l++;
    for(ll i=0;i<limit;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
    fft(a,1);
    fft(b,1);
    for(ll i=0;i<=limit;i++) c[i]=a[i]*b[i];
    fft(c,-1);
    for(ll i=0;i<=N+M;i++)
        c[i]=(ll)(c[i].x/limit+0.5);
    
    ll sum(0);
    for(ll i=0;i<=P-2;i++)
    {
        sum+=1ll*qpow(2,i)*(c[i].x+c[i+P-1].x);
    }
    ll sum2(0);
    for(ll i=1;i<=n;i++)
    sum2+=1ll*A[i]*A[i]%P;
    printf("%lld",(sum-sum2)/2);
    return 0;
}

Measured memory_bytes: 105012
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e2 + 10;
LL cnt[N];
int dp[2][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cnt[0] = 1;
	cnt[1] = 1;
	for (int i = 2; i < N; i++)
	{
		cnt[i] = cnt[i - 2] + cnt[i - 1];
		if (cnt[i] >= INF) cnt[i] -= INF;
	}
	dp[0][1] = 1;
	int o = 0;
	int h, w, k;
	cin >> h >> w >> k;
	for (int i = 1; i <= h; i++)
	{
		o ^= 1;
		MEM(dp[o], 0);
		for (int j = 1; j <= w; j++)
		{
			for (int s = max(j - 1, 1); s <= min(j + 1, w); s++)
			{
				int minv = min(s, j);
				int maxv = max(s, j);
				dp[o][s] = (dp[o ^ 1][j] * cnt[minv - 1] * cnt[w - maxv] + dp[o][s]) % INF;
			}
		}
	}
	cout << dp[o][k] << endl;
	return 0;
}

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


public class Main implements Runnable {

    private void solve() throws IOException {

        int[] arr = new int[] {  nextInt() , nextInt(), nextInt() };
        Arrays.sort(arr);
        if(arr[0] == 5 && arr[1] == 5 && arr[2] == 7) {
            writer.println("YES");
        } else writer.println("NO");

    }

    public static void main(String[] args) {

        new Main().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//             reader = new BufferedReader(new FileReader("input.txt"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while(tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }
}


Measured memory_bytes: 8148
/**
*   Author : Krishna Purohit
*/

#include "bits/stdc++.h"
#define sync ios_base::sync_with_stdio(false)
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define mod 10000000007
using namespace std;

ll t, n;

int main() {
    sync;
    cin >> n;
    string s;
    cin >> s;
    for(char &c : s) {
        c += (n);
        if(c > 90) c -= 26;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
mi=10**5
for a in range(1,n//2+1):
    b=n-a
    sa=str(a)
    sb=str(b)
    aa=list(map(int,list(sa)))
    ab=list(map(int,list(sb)))
    mi=min(mi,sum(aa)+sum(ab))
print(mi)

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

int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  
  for(int i=0;i<N;i++) cin >> W[i];
  int ans = 1e9;
  for(int i=1;i<N;i++){  
    int r=0;
    int l=0;
    for(int j=0; j<i; j++) l += W[j];
    for(int j=i; j<N; j++) r += W[j];
    ans = min(ans,abs(r-l));
  }
  cout << ans << endl;
}


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

int main(){
    int A[33];
    A[1] = A[2] = A[3] = A[5] = A[7] = A[11] = A[13] = A[15] = A[17] = A[19] = A[23] = A[29] = A[31] = 1;
    A[4] = A[6] = A[9] = A[10] = A[14] = A[21] = A[22] = A[25] = A[26] = 2;
    A[8] = A[12] = A[18] = A[20] = A[27] = 5;
    A[16] = 14;
    A[24] = 15;
    A[28] = A[30] = 4;
    A[32] = 51;

    int k;
    cin >> k;

    cout << A[k] << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc071.contest.atcoder.jp/tasks/arc071_a>
問題文============================================================
 すぬけ君は、文字列の書かれた紙から文字をいくつか切り抜いて、並び替えて別の文字列を作るのが好きです。
 
 明日になると、すぬけ君は文字列 S1,…,Sn のうちどれか 1 つが書かれた紙がもらえます。
 すぬけ君は文字列を作る事をとても楽しみにしているので、どんな文字列を作るか計画を立てることにしました。
 ただし、すぬけ君はまだどの文字列が書かれた紙がもらえるかを知らないため、
 どの文字列が書かれていた場合にも作れる文字列を考えることにしました。
 
 S1,…,Sn のどの文字列が書かれていても作れる文字列のうち、最長のものを求めてください。
 最長のものが複数ある場合は、辞書順で最小のものを求めてください。

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<string> S(n);
    for(auto &in:S) cin >> in;
    vector<vector<int>> alpha(n,vector<int>(26,0));
    for(int x = 0; x < n;x++){
        string & s = S[x];
        for(int i = 0; i < (int)s.length();i++){
            alpha[x][s[i]-'a']++;
        }
    }
    string ans ="";
    for(int i = 0; i < 26;i++){
        int minv = INF;
        for(int j = 0; j < n;j++){
            minv = min(minv,alpha[j][i]);
        }
        ans += string(minv,'a'+i);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int a,b;
	int MAX,MIN;
	int kari;
	int syoi;
	while (cin >> a >> b) {
		MAX = max(a,b);
		MIN = min(a,b);
		syoi = MAX % MIN;
		while (syoi != 0) {
			kari = MIN;
			MIN = MAX % MIN;
			MAX = kari;
			syoi = MAX % MIN;
		}
		cout << MIN << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int c = 4;
    int d = 7;
    int count = sc.nextInt();
    int total = 0;
    String answer = "No";
    for(int i=0;i<30;i++) {
      for(int j=0;j<30;j++) {
      	total = c * i + d * j;
        if(total == count) {
          answer = "Yes";
        }
      }
  	}
    System.out.println(answer);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;


// Z-Algorithm; 最長共通接頭辞
// ：文字列sとs[i, s|s|]の最長共通接頭辞の長さを返す。[O(|s|)]
vector<long long> z_algorithm(const string &s){
    vector<long long> prefix(s.size());
    for(long long i=1, j=0; i<(long long)s.size(); i++){
        if(i+prefix[i-j] < j+prefix[j]) prefix[i] = prefix[i-j];
        else{
            long long k = max(0LL, j+prefix[j]-i);
            while(i+k < (long long)s.size() && s[k] == s[i+k]) k++;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (long long)s.size();
    return prefix;
}

int main(){
    Init();
    ll n, ans = 0; string s;
    cin >> n >> s;

    // 開始文字をi文字目とした部分文字列で最長共通接頭辞を求める
    for(ll i=0; i<n-1; i++){
        string tmp = s.substr(i);
        auto lcp = z_algorithm(tmp);
        for(ll j=0; j<lcp.size(); j++){
            ll ls = min(lcp[j], j);
            chmax(ans, ls);
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;
	int a[105];

	cin >> N;
	rep(i,N) cin >> a[i];

	sort(a, a+N);
	reverse(a, a+N);

	rep(i,N){
		ans += a[i] * (i%2 ? -1 : 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
S = [int(x) for x in list(input())]

counter1 = 0
current_value = 0
for _ in S:
    if not _ == current_value:
        counter1 += 1
    if current_value == 0:
        current_value = 1
    else:
        current_value = 0

counter2 = 0
current_value = 1
for _ in S:
    if not _ == current_value:
        counter2 += 1
    if current_value == 0:
        current_value = 1
    else:
        current_value = 0

print(min([counter1, counter2]))


Measured memory_bytes: 4652
#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 FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

vector<int> tejun;

vector<int> solve(vector<int> v){
  /*REP(i,v.size()){
    cout<<v[i]<<"    ";
  }
  cout<<endl;*/
  REP(i,v.size()){
    if(v[i]>i+1){
    vector<int> dame;
    return dame;
    }
  }

    if(v.size() == 1&&v[0]==1){
      tejun.pb(1);
      return v;   //現場へお返ししまーす
    }

    REP(i,v.size()){
      if(v[i] == i+1){
        vector<int> v2;
        copy(v.begin(), v.end(), back_inserter(v2) );
        v2.erase(v2.begin() + i);
        vector<int> res = solve(v2);

        if(res.size() == 0){
          //だめだった。。。

        }else{
          tejun.pb(i+1);
          return v;
        }
      }
    }

    //ダメだった時
    vector<int> dame;
    return dame;

}

int main(){

  int n;
  cin>>n;
  vector<int> v;

  REP(i,n){
    int t;
    cin>>t;
    v.pb(t);
  }

  REP(i,n){
    if(v[i]>i+1){
      cout<<-1<<endl;
      return 0;
    }
  }

  solve(v);


  if(tejun.size() == 0){
    cout<<-1<<endl;
    return 0;
  }
  REP(i,n){
    cout<<tejun[i]<<endl;
  }

 

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;



public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		String S= sc.next();
		int maxline =0;
		for (int i=0;i<S.length()-maxline;i++) {
			for (int j=i+1;j<S.length()-maxline;j++) {
				int line =0;
				if (S.charAt(i)==S.charAt(j)) {
					line++;
					for (;line<j-i&&j+line<S.length();line++) {
						if (S.charAt(i+line)!=S.charAt(j+line)) {
							break;
						}
					}
					if(line>maxline) {
						maxline=line;
					}
				}
			}
		}
		System.out.println(maxline);
	}
}


Measured memory_bytes: 24276
import sys
n = int(input())
x = [int(i) for i in input().split()]
ans=1
for i in range(0,n):
    if x[i]==0:
        print(0)
        sys.exit()
for i in range(0,n):
    ans*=x[i]
    if ans>10**18:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 21572
n, m, k = map(int, input().split())

for i in range(n+1):
    for j in range(m+1):
        if i and j:
            ans = i * m + j * n - (i * j * 2)
        elif i > 0 and j == 0:
            ans = i * m
        elif i == 0 and j > 0:
            ans = j * n
        else:
            ans = 0
        if ans == k:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	string s, s2, s3;
	int m, n;

	while (true) {
		cin >> s;
		if (s == "-") break;
		cin >> m;
		for (int j = 0; j < m; j++) {
			cin >> n;

			s2 = s[n];
			for (int i = n + 1; i < s.length(); i++) {
				s2 += s[i];
			}
			for (int i = 0; i < n; i++) {
				s2 += s[i];
			}
			s = s2;
		}
		cout << s << "\n";
	}
}

Measured memory_bytes: 1204
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint N, M, K;
	cin >> N >> M >> K;
	vector<lint>A(N);
	vector<lint>B(M);
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, M) {
		cin >> B[i];
	}
	vector<lint>SA(N);
	vector<lint>SB(M);
	SA[0] = A[0];
	for (lint i = 1; i < N; i++) {
		SA[i] = SA[i - 1] + A[i];
	}
	SB[0] = B[0];
	for (lint i = 1; i < M; i++) {
		SB[i] = SB[i - 1] + B[i];
	}
	vector<lint>sa;
	vector<lint>sb;
	sa.push_back(0);
	sb.push_back(0);
	rep(i, N) {
		sa.push_back(SA[i]);
	}
	rep(i, M) {
		sb.push_back(SB[i]);
	}

	lint ans = 0;

	rep(i, N + 1) {
		lint j = upper(sb, K - sa[i]) - upper(sb,0);
		if (j >= 0) {
			ans = max(ans, i + j);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 14180
n=int(input())
a=list(map(int,input().split()))
ans=1
flag=0
for i in range(n-1):
  if a[i+1]>a[i]:
    if flag==-1:
      ans+=1
      flag=0
    else:
      flag=1
  if a[i+1]<a[i]:
    if flag==1:
      ans+=1
      flag=0
    else:
      flag=-1
print(ans)


Measured memory_bytes: 14224
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2
minxy = min(x, y)
ans = 0

if ave > ab:
    ans += 2 * minxy * ab
    if x > y:
        if a < ab * 2:
            ans += (x - minxy) * a
        else:
            ans += (x - minxy) * 2 * ab
    else:
        if b < ab * 2:
            ans += (y - minxy) * b
        else:
            ans += (y - minxy)  * 2 * ab
else:
    ans = a * x + b * y
    
print(ans)

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

int main() {
  int n,a,b;
  cin >> n>>a>>b;
  vector<double> vec(n);
  
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  double ondosa=1000;
  int answer;
  for(int i=0;i<n;i++){
    if(abs(b-(a-vec.at(i)*0.006))<ondosa){
      ondosa=abs(b-(a-vec.at(i)*0.006));
      answer=i+1;
    }
  }
  
  cout<<answer<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	a := scanInt()
	b := scanInt()
	c := scanInt()
	kawaiso := false

	switch true {
	case a == b:
		kawaiso = true
	case b == c:
		kawaiso = true
	case a == c:
		kawaiso = true
	}
	if a == b && b == c {
		kawaiso = false
	}
	if kawaiso {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
A,B = [],[]
for num in range(n):
    if(num == 0 or num % 2 == 0):
        A.append(a[num])
    else:
        B.append(a[num])
print(sum(A)-sum(B))

Measured memory_bytes: 9088
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define READ freopen("in.txt", "r", stdin)
#define ROUT freopen("out.txt", "w", stdout)
#define pb push_back
#define endl '\n'

#define REP(i,a,b) for(int i=a; i<=b; i++)
#define arrL(i,a,b) for(int i=a; i<b; i++)

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    ROUT;
}

void solve()
{
    ll a, b, k;
    cin>>a>>b;
    k=(a*a-b*b)/2/(a-b);
    if(abs(a-k)==abs(b-k))
        cout<<k<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
}

int main()

{
    ///fileIO();
    fasterIO();

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

typedef long long i64; 
typedef vector< int > vi;
typedef vector< i64 > vi64;
typedef pair< int, int > pi;
typedef vector< pair< int, int > > vpi;

void crypt() {
	int n, k; cin >> n >> k;
	int ans = k;
	fore(i, 1, n-1, 1) ans *= (k-1);
	cout << ans << "\n";
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	cout << fixed;
	int t = 1; 
//	cin >> t;
	while (t--) crypt();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;

    if(a.size() ==  b.size()){
        for (int i = 0; i < a.size(); i++){
            if(a[i] > b[i]) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }else{
                continue;
            }
        }
        cout << "EQUAL" << endl;
    }
    else if (a.size() < b.size()) cout << "LESS" << endl;
    else cout << "GREATER" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0 || j==0)
			dp[i][j]=0;
		else	if(s[i-1]==t[j-1])
			dp[i][j]=1+dp[i-1][j-1];
			else
			dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	char ch[dp[n][m]+1];
	int i=n,j=m;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ch[dp[i][j]]=s[i-1];
			i-- ,j--;
		}
		else if(dp[i-1][j]<dp[i][j-1])
		{
			j--;
		}
		else 
		i--;
	}
	for(int i=1;i<=dp[n][m];i++)
	cout<<ch[i];
	cout<<endl;
}

Measured memory_bytes: 35456
Q=int(input())
prime = [1]*(10**5+1)
prime[0],prime[1]=0,0
for i in range(2,int(pow(10**5,0.5)+3)):
    if not prime[i]:
        continue
    for j in range(i*2,10**5+1,i):
        prime[j]=0
near_2017 = [1]*(10**5+1)
near_2017[0:3]=[0,0,0]
for i in range(3,10**5+1):
    if prime[i] and prime[(i+1)//2]:
        near_2017[i]=near_2017[i-1]+1
    else:
        near_2017[i]=near_2017[i-1]
for i in range(Q):
    l,r=map(int,input().split(' '))
    print(near_2017[r]-near_2017[l-1])

Measured memory_bytes: 4980
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int n, m;

void init()
{
	cin >> n >> m;
}


int main()
{
	init();
	ll ans;

	if (abs(n - m) > 1)
	{
		cout << 0 << endl;
		return 0;
	}
	else if (n == m)
	{
		ans = 2;
		REP1C(i, n)
		{
			ans = ans * i % MOD;
		}

		REP1C(i, m)
		{
			ans = ans * i % MOD;
		}
	}

	else
	{
		ans = 1;
		REP1C(i, n)
		{
			ans = ans * i % MOD;
		}

		REP1C(i, m)
		{
			ans = ans * i % MOD;
		}

	}

	cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  int X = (100*N)/108;
  if ((int)(X*1.08) == N) cout << X << endl;
  else if ((int)((X+1)*1.08) == N) cout << X + 1 << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 100003
#define Ll long long 
int n,q,a[M],l=1e9,r=-1,c[M<<1],z,s[M<<1+1];
inline int read(){
	int x=0,f=1;
    char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int lowbit(int n){return n&(-n);}
void up(int i,int y){for(;i<=n;i+=lowbit(i))c[i]+=y;}
int sum(int r){
	int ans=0;
	for(;r>0;r-=lowbit(r))ans+=c[r];
	return ans;
}
bool zzws(int len){
    Ll ans=0;
    int N=n;
    for(int i=1;i<=n;++i)s[i]=a[i]>=len?-1:1;
    for(int i=1;i<=n;++i){
        s[i]+=s[i-1];
        ans+=(s[i]>0);
        N=min(N,s[i]);
        }
    for(int i=1;i<=n;++i){
        c[i]=0;
        s[i]+=(1-N);
        }
    for(int i=1;i<=n;++i){
        ans+=sum(s[i]-1);
        up(s[i],1);
        }
    return ans <= 1ll * n* ( n + 1 ) / 4;
}
int main(){
    n=read();
	for(int i=1;i<=n;i++){
    a[i]=read();
    l=min(a[i],l),r=max(a[i],r);
	}
    while(r>l+1){
        int mid=(l+r)>>1;
        if(zzws(mid))l=mid;
        else r=mid-1;
    }
    if(zzws(r))printf("%d\n",r);
    else printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 4936
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int h = sc.nextInt(), w = sc.nextInt(), hh = sc.nextInt(), ww = sc.nextInt();
		System.out.println((h - hh) * (w - ww));
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int, int> P;

class UnionFind{
public:
	vector<int> par,num;
 
	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UnionFind(int N):par(N),num(N,1){
		iota(par.begin(),par.end(),0);
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return ;
		if(num[u]<num[v])swap(u,v);
		num[u] += num[v];
		par[v] = u;
	}
	bool same(int u,int v){
		return find(u) == find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>p(n);
    for(int i=0;i<n;i++)cin>>p.at(i);
    UnionFind Uf(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        Uf.unite(x-1,y-1);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(Uf.same(i,p.at(i)-1))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        if (s.equals(u)) {
            System.out.println((a - 1) + " " + b);
        } else {
            System.out.println(a + " " + (b - 1));
        }
    }

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,d,ans=0;
    cin>>n>>d;
    for(int i=0; i<n; i++){
        double x,y;
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3804