akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
int power[20];
void function2()
{
	power[0]=1;
	int j;
	for(j=1;j<20;j++)
	{
		power[j]=2*power[j-1];
	}
}
int binary_search(int prefix[][20],int index,int start,int end,int first)
{
	if(start>end)
	   return -1;
	else
	{
		int mid=(start+end)/2;
		int here=prefix[mid][index]-prefix[first-1][index];
		if(here<=1)
		{
			int x=mid;
			int y=binary_search(prefix,index,mid+1,end,first);
			if(y==-1)
			   return x;
			else
			   return y;
		}
		else
		{
			return binary_search(prefix,index,start,mid-1,first);
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	function2();
	int n;
	cin>>n;
	int j,arr[n+1];
	for(j=1;j<=n;j++)
	{
		cin>>arr[j];
	}
	int prefix[n+1][20]={0};
	int i;
	for(j=1;j<=n;j++)
	{
		int x=arr[j];
		for(i=19;i>=0;i--)
		{
			if(x>=power[i])
			{
				prefix[j][i]++;
				x-=power[i];
			}
		}
	}
	for(i=0;i<20;i++)
	{
		for(j=1;j<=n;j++)
		{
			prefix[j][i]+=prefix[j-1][i];
		}
	}
	int answer=0;
	for(j=1;j<=n;j++)
	{
		set<int> st;
		for(i=0;i<20;i++)
		{
			int index=binary_search(prefix,i,j,n,j);
			st.insert(index);
		}
		int most=*st.begin();
		answer+=(most-j+1);
	}
	cout<<answer<<endl;
}


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

using namespace std;

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

    string S;
    cin >> S;
    int n = S.size();
    vector<int> res(n, 0);
    for (int i = 0, j = 0; i < n; ++i) {
        if (S[i] == 'R') {
            j = max(i, j);
            while (j < n && S[j] == 'R') {
                ++j;
            }
            assert(j < n);
            int dist = j - i;
            if (dist % 2 == 1) {
                ++res[j - 1];
            } else {
                ++res[j];
            }
        }
    }
    for (int i = n - 1, j = n - 1; i >= 0; --i) {
        if (S[i] == 'L') {
            j = min(i, j);
            while (j >= 0 && S[j] == 'L') {
                --j;
            }
            assert(j >= 0);
            int dist = i - j;
            if (dist % 2 == 1) {
                ++res[j + 1];
            } else {
                ++res[j];
            }
        }
    }
    for (int x : res) {
        cout << x << " ";
    }
    cout << "\n";

    return 0;
}

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

int main() {
    string s, p;
    
    getline(cin, s);
    getline(cin, p);
    s += s;
    
    
    if (s.find(p) != string::npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No"  << endl;   
    }
    
    return 0;
}


Measured memory_bytes: 3200
/**
 *      ABC 46 C
 *      author  : kyomukyomupurin
 *      created : 2018-10-01 21:08:27
**/

#include <bits/stdc++.h>
using namespace std;
/*
int64_t gcd(int64_t x, int64_t y){
    if (x % y == 0){
        return y;
    }
    else {
        return gcd(y, x % y);
    }
}

int64_t lcm(int64_t x, int64_t y){
    if (x % y == 0 || y % x == 0){
        return max(x, y);
    }
    else {
        return x * y / gcd(x, y);
    }
}
*/
int64_t mag(int64_t x1, int64_t x2){
    if (x1 % x2 == 0){
        return x1 / x2;
    }
    else {
        return x1 / x2 + 1;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int32_t N; cin >> N;
    int64_t T[N] = {}; int64_t A[N] = {};
    for (auto i = 0; i < N; ++i) {
        cin >> T[i] >> A[i];
    }

    for (auto i = 1; i < N; ++i) {
        if (T[i] < T[i - 1] || A[i] < A[i - 1]){
            int64_t magni = max(mag(T[i - 1], T[i]), mag(A[i - 1], A[i]));
            T[i] *= magni; A[i] *= magni;
        }
    }

    cout << T[N - 1] + A[N - 1] << '\n';
    
    return 0;
}

Measured memory_bytes: 256
N,Z,W=map(int,input().split())
a=list(map(int,input().split()))

#最後のカードをどちらかが引くことになる
#Xが最後のカードまで一気に引く場合
score=abs(a[N-1]-W)

#Xが任意の枚数を取ってスコアを大きくする時、YはN-2番目まで取ってabs(a[N-2]-a[N-1])まではスコアを小さくすることができる。
#逆にYが任意の枚数を取ってスコアを小さくする時、Xはこの値までスコアを大きくできる。
#よって、Xが期待できるスコアの最大値はabs(a[N-2]-a[N-1])になる。
print(max(score,abs(a[N-2]-a[N-1])))

'''
drawcount=0 #2人が引いた枚数
score=[0]*N #XがN枚引いた時の最少スコアを格納
score[N-1]=abs(a[N-1]-W) #Xが全部引いた時のスコア

for i in range(N-1):
  Xscore=a[i]
  print(Xscore)
  score[i]=10**9
  for j in range(i+1,N):
  	score[i]=min(abs(a[i]-a[j]),score[i])
  	print(score)
print(max(score))
'''

Measured memory_bytes: 3188
import java.util.Scanner;

/**
 * @program: leetcode
 * @description:
 * @author: wangtengke
 * @create: 2019-06-16
 **/
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int[] L = new int[n];
        for(int i=0; i<n; i++){
            L[i] = scanner.nextInt();
        }
        int res = solve(L, n, x);
        System.out.println(res);
    }

    private static int solve(int[] l, int n, int x) {
        int count = 1;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if(sum + l[i]>x) break;
            sum += l[i];
            count++;

        }
        return count;
    }

}


Measured memory_bytes: 22356
N,Y=map(int,input().split())
f=Y//10000
for x in range(f+1):
    for y in range(N+1):
        z=N-x-y
        k=10000*x+5000*y+1000*z
        if k==Y and x+y+z==N and z>=0:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
n = int(input())
s = input()
app = [[False, [[False, [False for k in range(10)]] for j in range(10)]] for i in range(10)]
count = 0
for num in s:
    num = int(num)
    for i in range(10):
        if app[i][0]:
            for j in range(10):
                if app[i][1][j][0]:
                    # print("{}{}{}=True".format(i,j,num))
                    if not app[i][1][j][1][num]:
                        count += 1
                        app[i][1][j][1][num] = True
            # print("{}{}=True".format(i,num))
            app[i][1][num][0] = True
    # print("{}=True".format(num))
    app[num][0] = True
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
template<typename DATA_TYPE, typename LAZY_TYPE, typename F, typename G, typename H>
class SegmentTree {
  private:
	size_t size;

	F f;
	G g;
	H h;

	std::vector<DATA_TYPE> data;
	std::vector<LAZY_TYPE> lazy;
	DATA_TYPE data_init;
	LAZY_TYPE lazy_init;

	SegmentTree() : size(0) {}

	void eval(int length, size_t index) {
		if (lazy[index] == lazy_init) return;
		if (index * 2 + 1 < size * 2 - 1) {
			lazy[index * 2 + 1] = h(lazy[index * 2 + 1], lazy[index]);
			lazy[index * 2 + 2] = h(lazy[index * 2 + 2], lazy[index]);
		}
		data[index] = g(data[index], lazy[index], length);
		lazy[index] = lazy_init;
	}

	DATA_TYPE update(size_t begin, size_t end, LAZY_TYPE update_value, size_t index, size_t left, size_t right) {
		eval(right - left, index);
		if (right <= begin || end <= left) return data[index];
		if (begin <= left && right <= end) {
			lazy[index] = h(lazy[index], update_value);
			return g(data[index], lazy[index], right - left);
		}
		return data[index] = f(update(begin, end, update_value, index * 2 + 1, left, (left + right) / 2), update(begin, end, update_value, index * 2 + 2, (left + right) / 2, right));
	}

	DATA_TYPE query(size_t begin, size_t end, size_t index, size_t left, size_t right) {
		eval(right - left, index);
		if (right <= begin || end <= left) return data_init;
		if (begin <= left && right <= end) return data[index];
		return f(query(begin, end, index * 2 + 1, left, (left + right) / 2), query(begin, end, index * 2 + 2, (left + right) / 2, right));
	}

  public:
	SegmentTree(size_t data_size, F f, G g, H h, DATA_TYPE data_init, LAZY_TYPE lazy_init) : f(f), g(g), h(h), data_init(data_init), lazy_init(lazy_init) {
		size = 1;
		while (size < data_size) size <<= 1U;
		data.resize(2 * size - 1, data_init);
		lazy.resize(2 * size - 1, lazy_init);
	}

	void build(std::vector<DATA_TYPE> input_data) {
		if (input_data.size() > size) {
			std::cerr << "segment tree::build : input oversize data\n";
			exit(-1);
		}
		for (int i = 0; i < input_data.size(); ++i) {
			data[i + size - 1] = input_data[i];
		}
		for (int i = size - 2; i >= 0; --i) {
			data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	void update(size_t begin, size_t end, LAZY_TYPE update_value) {
		update(begin, end, update_value, 0, 0, size);
	}

	DATA_TYPE query(size_t begin, size_t end) {
		return query(begin, end, 0, 0, size);
	}
};
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	auto f = [](int a, int b) { return a + b; };
    auto g = [](int a, int b, size_t len) { return b == INT_MIN ? a : b * len; };
	auto h = [](int a, int b) { return b == INT_MIN ? a : b; };
	int n, q;
	cin >> n >> q;
	SegmentTree<int, int, decltype(f), decltype(g), decltype(h)> segTree(n, f, g, h, 0, INT_MIN);
	rep(i, q) {
		int qt;
		cin >> qt;
		if (qt) {
			int s, t;
			cin >> s >> t;
			cout << segTree.query(s, t + 1) << endl;
		}
		else {
			int s, t, x;
			cin >> s >> t >> x;
			segTree.update(s, t + 1, x);
		}
	}
}



Measured memory_bytes: 7084
#include <stdio.h>

 int main()
 {

 int a[10000], min, max, n, i;
 long long sum = 0;
 scanf("%d", &n);
for(i = 0; i < n; i++){
 scanf("%d", &a[i]);
 sum += a[i];
 }
 max = min = a[0];
for(i = 1; i < n; i++){
if(a[i] > max)max = a[i];
 if(a[i] < min)min = a[i];
 }
 printf("%d %d %lld\n", min, max, sum);

 return 0;
 }

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

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


Measured memory_bytes: 256
A,B,C=map(int,input().split())
K=int(input())
abc=[A,B,C]
#赤＜緑＜青
for _ in range(K):
    if abc[0]>=abc[1]:
        abc[1]=abc[1]*2
    elif abc[1]>=abc[2]:
        abc[2]=abc[2]*2
    else:
        print("Yes")
        exit()

if abc[0]<abc[1] and abc[1]<abc[2]:
    print("Yes")
else:
    print("No")


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

int main(void) {
    int N;
    cin >> N;
    vector< pair< int, int > > e[N];
    for (int i = 0; i < N - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        e[u].push_back(make_pair(v, w));
        e[v].push_back(make_pair(u, w));
    }
    vector< int > color(N);
    for (int i = 0; i < N; ++i) {
        color[i] = -1;
    }
    color[0] = 0;
    queue< int > q;
    q.push(0);
    while (!q.empty()) {
        int i = q.front();
        q.pop();
        for (pair< int, int > p : e[i]) {
            int v = p.first;
            int w = p.second;
            if (color[v] >= 0) {
                continue;
            } else if (w % 2 == 0) {
                color[v] = color[i];
            } else {
                color[v] = (color[i] + 1) % 2;
            }
            q.push(v);
        }
    }
    for (int i = 0; i < N; ++i) {
        printf("%d\n", color[i]);
    }
    return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <cmath>

using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,m;
  cin>>n>>m;
  using P = pair<Int, Int>;
  vector<vector<P> > G(n);
  for(Int i=0;i<n-1;i++){
    Int u,v,c;
    cin>>u>>v>>c;
    u--;v--;
    G[u].emplace_back(v,c);
    G[v].emplace_back(u,c);
  }
  vector<Int> w(n);
  for(Int i=0;i<n;i++) cin>>w[i];
  priority_queue<Int> pq;
  vector<Int> dp(n);
  function<void(Int, Int, Int)> dfs=[&](Int r,Int v,Int p){
    for(auto e:G[v]){
      Int u=e.first;
      if(u==p) continue;
      dfs(r,u,v); 
    }
    Int idx=-1;
    for(auto e:G[v]){
      Int u=e.first,c=e.second;
      if(u==p) continue;
      if(idx<0||dp[u]+c>dp[v])
	idx=u,dp[v]=dp[u]+c;
    }
    if(idx<0){
      dp[v]=0;
      return;
    }
    for(auto e:G[v]){
      Int u=e.first,c=e.second;
      if(u==p) continue;
      if(u==idx) continue;
      pq.emplace((dp[u]+c)*w[r]);
    }
    if(v==r) pq.emplace(dp[v]*w[r]);
  };
  
  for(Int i=0;i<n;i++) dfs(i,i,-1);
  
  Int ans=0;
  while(m&&!pq.empty()){
    ans+=pq.top();pq.pop();
    m--;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;

char c[123][123];

int a, b;
int n, m;
bool change = 0;
char cw = '.', cb = '#';

void print() {
  cout << n << ' ' << m << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (change)
        c[i][j] = (c[i][j] == cw) ? cb : cw;
      printf("%c", c[i][j]);
    }
    puts("");
  }
  exit(0);
}

main() {
  scanf("%d %d", &a, &b);
  n = min(99, max(a, b) * 3);
  m = 100;
  bool fl = 1;
  change = 0;
  if (a > b) {
    swap(a, b);
    swap(cw, cb);
  }
  for (int i = 2; i <= n; i += 3) {
    for (int j = 1; j <= m; j++) {
      c[i - 1][j] = c[i][j] = c[i + 1][j] = ((fl) ? cb : cw);
    }
    if (fl) {
      b--;
    } else {
      a--;
    }
    fl ^= 1;
  }
  cerr << a << ' '  << b << endl;
  for (int i = 8; i <= n && a < 0; i += 6) {
    c[i][1] = c[i - 1][1] = c[i + 1][1] = cw;
    a++;
  }
  for (int i = 5; i <= n && b > 0; i += 6) {
    for (int j = 3; j <= m && b > 0; j += 2) {
      c[i][j] = cb;
      b--;
    }
  }
  for (int i = 2; i <= n && a > 0; i += 6) {
    for (int j = 3; j <= m && a > 0; j += 2) {
      c[i][j] = cw;
      a--;
    }
  }
  print();
}


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

int Manhattan(int x1, int x2, int y1, int y2){
  int xman = x1 - x2;
  if(xman < 0) xman *= (-1);

  int yman = y1 - y2;
  if(yman < 0) yman *= (-1);

  return xman + yman;

}



int main(){

  int N, M;

  cin >> N >> M;

  int point[N][2];
  int check[M][2];

  int min[N][2];


  for(int i = 0; i < N; i++){
    cin >> point[i][0] >> point[i][1]; 
  }

  for(int i = 0; i < M; i++){
    cin >> check[i][0] >> check[i][1];

    for(int j = 0; j < N; j++){

      // cout << "Manhattan" << i << "-" << j << " = "
      // 	   << Manhattan(point[j][0], check[i][0], point[j][1], check[i][1])
      // 	   << endl;

      if(0 == i){
	min[j][0] = i + 1;
	min[j][1]
	  = Manhattan(point[j][0], check[i][0], point[j][1], check[i][1]);
      }

      if(min[j][1]
	 > Manhattan(point[j][0], check[i][0], point[j][1], check[i][1])){
	min[j][0] = i + 1;
	min[j][1]
	  = Manhattan(point[j][0], check[i][0], point[j][1], check[i][1]);
      }
      // cout << '(' << min[j][0] << ", " << min[j][1] << ')'<< endl;
    
    }
  }
  

  for(int i = 0; i < N; i++){
    cout << min[i][0] << endl;
  }


  return 0;
}


Measured memory_bytes: 256
struct UnionFindTree {
    par: Vec<usize>,
}

impl UnionFindTree {
    fn new(n: usize) -> UnionFindTree {
        UnionFindTree {
            par: (0..n).collect(),
        }
    }

    fn root(&mut self, x: usize) -> usize {
        let p = self.par[x];
        if p == x {
            x
        } else {
            let r = self.root(p);
            self.par[x] = r;
            r
        }
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    fn unite(&mut self, x: usize, y: usize) {
        let rootx = self.root(x);
        let rooty = self.root(y);
        if rootx == rooty {
            ;
        } else {
            self.par[rootx] = rooty;
        }
    }
}

fn main() {
    let s = read_string();
    let mut sc = Scanner::new(&s);

    let n: usize = sc.next();
    let m: usize = sc.next();

    let mut ps = Vec::with_capacity(n);

    for _i in 0..n {
        let p: usize = sc.next();
        ps.push(p-1);
    }

    let mut uf = UnionFindTree::new(n);

    for _i in 0..m {
        let x: usize = sc.next();
        let y: usize = sc.next();
        uf.unite(x-1, y-1);
    }

    let mut ans = 0;

    for i in 0..n {
        if uf.same(ps[i], i) {
            ans += 1;
        }
    }

    println!("{}", ans);
}

// 以下、たなこふ先生からぱくったやつ (´･_･`)

struct Scanner<'a> {
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Scanner<'a> {
    fn new(s: &str) -> Scanner {
        Scanner {
            iter: s.split_whitespace(),
        }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        let s = self.iter.next().unwrap();
        s.parse().unwrap()
    }
}

fn read_string() -> String {
    use std::io::Read;

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    buf
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

int main() {
    int m, d;
    int cnt = 0;
    cin >> m >> d;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            if (j < 10 || j > 100) continue;
            int d_1 = j % 10;
            int d_10 = j / 10;
            if (d_1 >= 2 && d_10 >= 2 && i == d_1 * d_10) cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 100001;

int n, k, s;
int a[MAX];

void solve() {
    for (int i = 0; i < k; i++)
        a[i] = s;
    for (int i = k; i < n; i++)
        a[i] = s + 1 <= 1000000000 ? s + 1 : s - 1;
    for (int i = 0; i < n; i++)
        fprintf(out, "%d%c", a[i], i + 1 == n ? '\n' : ' ');
}

int main(void) {
	// in = fopen("C.in", "rt");
	
	fscanf(in, "%d %d %d", &n, &k, &s);
	solve();
	
	return 0;
}

Measured memory_bytes: 1664
n = int(input()); a = list(map(int, input().split())); b = -1; x = 1
for i in range(n-1):
    if b == 0:
        if a[i] > a[i+1]: b = -1; x += 1
    elif b == 1:
        if a[i] < a[i+1]: b = -1; x += 1
    else:
        if a[i] < a[i+1]: b = 0
        elif a[i] > a[i+1]: b = 1
print(x)

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

#define endl '\n'
#define INF 1e9 + 10
#define rep(i,s,n)      for (int i = s ; i < n ; i++)
#define repp(i,s,n)    for (int i = s ; i <= n ;i++)
#define all(a)      a.begin(),a.end()
#define sz(v)    (int)v.size()
#define digg(n)    ((long long)log10(n)+1)
#define Unique(n)         (n).erase(unique(all(n)), (n).end())
#define tests    int s ; cin >> s; while (s--)
#define test    int tt = 1 ; while (tt--)
#define readArr    int n ; cin >> n ; int arr[n]; rep(i,0,n)cin>>arr[i]
#define isvowel(a)   (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fast     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define s second
#define f first
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " : " << arg1 <<'\n';
}
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...);
}

// to be noted >> corner cases >>

typedef long long ll ;
typedef pair<int,int> pii;
typedef vector<long long> vll;
typedef vector<pii>vii;
typedef map<long long, long long> mll ;


void readFromText ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

void print(int arr [], int n)
{
    rep(i,0,n)cout<< arr[i] << " ";
    cout << endl ;
}

vll dig(ll n)
{
    vll res;
    if(n == 0)
    {
        res.pb(0);
        return res;
    }
    while(n != 0)
        res.pb(n % 10), n /= 10;
    return res;
}

vll bin(ll a)
{
    vll res;
    while(a != 0)
        res.pb(a % 2), a /= 2;
    while((ll)res.size() != 64)
        res.pb(0);
    return res;
}

ll gcd(ll a, ll b)
{
    if(b == 0)
        return a;
    return gcd(b, a%b);
}

string longDivision(string number, long long divisor)
{
    string out;
    int indx = 0;
    long long temp = number[indx] - '0';
    while (temp < divisor)
        temp = temp * 10 + (number[++indx] - '0');
    while (number.size() > indx)
    {
        out += (temp / divisor) + '0';
        temp = (temp % divisor) * 10 + (number[++indx] - '0');
    }
    if (out.length() == 0)
        return "0" ;
    return out;
}

//bool fun (item i , item j) {
//
//}

const double Pi = acos(-1.0);
const int MAX = 2e5 ;
int pref[MAX+9];

int main()
{
    fast;
//    readFromText();
    test{
        string s , t ; cin >> s >> t ;
        int counter = 0 ;
        rep(i,0,s.length())if(s[i]!=t[i])counter++;
        cout << counter << endl ;
    }
    return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<string>
using namespace std;
int main() {
  	char a;
	string s;
  	string t;
  	cin >> s;
  	cin >> t;
  	int i;
  	for(i = 1; s[i] != 0; i++) {
      	for(int j = i; j != 0; j--) {
          	if(s[j - 1] > s[j]) {
              	a = s[j - 1];
              	s[j - 1] = s[j];
              	s[j] = a;
            }
        }
    }
  	int k;
  	for(k = 1; t[k] != 0; k++) {
      	for(int j = k; j != 0; j--) {
          	if(t[j - 1] < t[j]) {
              	a = t[j - 1];
              	t[j - 1] = t[j];
              	t[j] = a;
            }
        }
    }
  	int l = 0;
  	for(i = 0; t[i] != 0; i++) {
      	if(s[i] > t[i]){
          	break;
        }else if(s[i] < t[i]) {
        l = 1; break;
        }
    }
  	if(l == 0) {
      	cout << "No" << endl;
    }else{
      	cout << "Yes" << endl;
    }
  	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int main() {
	double r;
	cin >> r; 
	double res = 2 * M_PI * r;
	printf("%.12lf\n", res);

	return 0;
}

Measured memory_bytes: 3788
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=INF,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  REP(i,(s.size()-2)){
    c = min(c,abs(753 - stoll(s.substr(i,3))));
  }
  OUT(c);
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,j,g,min,h=0,count=0,x,n[100];
  scanf("%d",&g);
  for(i=0;i<g;i++)scanf("%d",&n[i]);
  for(i=0;i<g;i++){
    min = i;
    h=0;
    for(j=i;j<g;j++){
      if(n[j] < n[min]){
	min = j;
        h++;}
    }
    if(h>0){
	x = n[i];
	n[i] = n[min];
	n[min]= x;
	count++;
    }}

  for(i=0;i<g;i++){
    printf("%d",n[i]);
    if(i<g-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 604
using System;



class Program
{
    static void Main(string[] args)
    {
        Input CInput = new Input();
        int input = 0;
        //int[] input = new int[(int)Input.Define.MAX_ArraySize];
        //int[,] input = new int[(int)Input.Define.MAX_ArraySize, (int)Input.Define.ArraySize2d];
        //int num = 0;
        input = CInput.Line1_int();
        //input = CInput.Multiline_int(' ', 2, ref num);


        for (int i = 1; i <= input; i++)
        {
            var x = i;
            if (x % 3 == 0)
            {
                System.Console.Write(" {0}", i);
            }
            else
            {
                while (true)
                {
                    if (x % 10 == 3)
                    {
                        System.Console.Write(" {0}", i);
                        break;
                    }
                    x /= 10;
                    if (x == 0) break;
                }
            }
        }
        System.Console.WriteLine();
    }
}








class Input
{
    public enum Define
    {
        MAX_ArraySize = 1000000,
        ArraySize2d = 2,                // 2?¬?????????????[][?] ???????
    }

    public string Line1_string()
    {
        return Console.ReadLine();
    }

    public int Line1_int()
    {
        var input = Console.ReadLine();
        return int.Parse(input);
    }

    public double Line1_double()
    {
        var input = Console.ReadLine();
        return double.Parse(input);
    }

    public int[] Line1_int(int chr, int num)
    {
        var input = Console.ReadLine();
        var split = input.Split(' ');
        int[] spliti = new int[100];
        for (int i = 0; i < num; i++)
        {
            spliti[i] = int.Parse(split[i]);
        }
        return spliti;
    }

    public int[] Multiline_int(ref int datanum)
    {
        int i = 0;
        int[] data = new int[(int)Input.Define.MAX_ArraySize];
        while (true)
        {
            var input = Console.ReadLine();
            var value = int.Parse(input);
            if (value == 0) break;
            data[i] = value;
            i++;
        }
        datanum = i;
        return data;
    }
    /// <summary>
    /// ?????°??????int??????????????????????????????
    /// </summary>
    /// <param name="chr">???????????????</param>
    /// <param name="num">?????????????????????????????°</param>
    /// <param name="datanum">??????????????????????????°</param>
    /// <returns></returns>
    public int[,] Multiline_int(int chr, int num, ref int datanum)
    {
        int i = 0;
        int[,] data = new int[(int)Input.Define.MAX_ArraySize, (int)Input.Define.ArraySize2d];
        while (true)
        {
            var input = Console.ReadLine();
            var split = input.Split(' ');
            int[] spliti = new int[100];
            for (int j = 0; j < num; j++)
            {
                spliti[j] = int.Parse(split[j]);
            }
            if (spliti[0] == 0 && spliti[1] == 0) break;
            data[i, 0] = spliti[0];
            data[i, 1] = spliti[1];
            i++;
        }
        datanum = i;
        return data;
    }

}

Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

    string s;

    cin >> s;

    int idx,ans = 0;

    for(int i = 0;i < s.length();i++)
    {
        if(s[i]=='C'){ idx = i; ans++; }
        if(s[i]=='A' and i!=0){ cout << "WA"; return 0; }
            if(s[i]<='Z')
            {
                if(s[i]!='A' and s[i]!='C'){ cout << "WA"; return 0; }
            }
    }

    if(ans!=1){ cout << "WA"; return 0; }
    if(idx<2 or idx>=s.length()-1){ cout << "WA"; return 0; }
    if(s[0]!='A'){ cout << "WA"; return 0; }

    cout << "AC";

}


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

ll pow(ll x,ll y){
  if(y==0){
    return 1;
  }else if(y==1){
    return x%MOD;
  }else if(y%2==0){
    return pow(x,y/2)*pow(x,y/2)%MOD;
  }else{
    return pow(x,y-1)*x%MOD;
  }
}

int main(){
  ll N,M;cin >> N >> M;
  if(M==1){
    cout << 1 << endl;
    return 0;
  }
  vector<ll> P;
  vector<ll> S;
  for(ll i=2;i*i<=M;i++){
    if(M%i==0){
      ll cnt = 0;
      while(M%i==0){
        cnt ++;
        M /= i;
      }
      P.push_back(i);
      S.push_back(cnt);
    }
  }
  if(M>1){
    P.push_back(M);
    S.push_back(1);
  }
  ll Smax=0;
  for(int i=0;i<S.size();i++){
    Smax = max(Smax,S[i]);
  }
  vector<ll> inv(Smax+1);
  inv[1] = 1;
  for(ll i=2;i<=Smax;i++){
    inv[i] = pow(i,MOD-2);
  }
  ll ans = 1;
  //N-1+S[i] C S[i]
  for(int i=0;i<P.size();i++){
    ll x = 1;
    for(int j=1;j<=S[i];j++){
      x = x * (N-1+j) % MOD;
      x = x * inv[j] % MOD;
    }
    ans = ans * x % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
#include <queue>
#include <utility>
#include <functional>
#include <list>


using namespace std;

struct Point
{
    double x, y;

    Point() {};
    Point(double x, double y): x(x), y(y) {};

    Point operator-(const Point & p) const
    {
        // Point difference = {x - p.x, y - p.y};
        // return difference;
        return Point(x - p.x, y - p.y);
    }

    double operator*(const Point & p) const
    {
        return x*p.x + y*p.y;
    }

    Point operator*(double c) const
    {
        // Point p = {c*x, c*y};
        // return p;
        return Point(c*x, c*y);
    }

    friend Point operator*(double c, const Point & p)
    {
        return p*c;
    }

    friend ostream & operator<<(ostream & os, const Point & p) 
    {
        os << setprecision(8) << fixed << p.x << ' ' << p.y << endl;
        return os;
    }

    friend istream & operator>>(istream & is, Point & p)
    {
        is >> p.x >> p.y;
        return is;
    }

    Point operator+(const Point & p) const
    {
        // Point sum = {x+p.x, y+p.y};
        // return sum;
        return Point(x+p.x, y+p.y);
    }

    Point projection(const Point & p1, const Point & p2) const
    {
        Point a(*this-p1), b(p2-p1);
        return (a*b)/(b*b)*b+p1;
    }

    Point reflection(const Point & p1, const Point & p2) const
    {
        return this->projection(p1, p2)*2 - *this;
    }


};


int main()
{
    Point p1, p2, p;

    cin >> p1 >> p2;

    int q;
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> p;
        cout << p.reflection(p1, p2);
    }


}


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

int main() {
    string n;
    cin>>n;
    if (n[n.size()-1]=='3') cout<<"bon"<<endl;
    else if(n[n.size()-1]=='0'||n[n.size()-1]=='1'||n[n.size()-1]=='6'||n[n.size()-1]=='8') {
        cout<<"pon"<<endl;
    } else {
        cout<<"hon"<<endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    cin >> n;
    long long int a[5];
    for(int i=0;i<5;i++)cin >> a[i];
    long long int ans=0;
    long long int MIN=1e15+1;    
    ans+=(n+a[0]-1)/a[0];
    MIN=min(MIN,a[0]);
    for(int i=1;i<5;i++){
        if(a[i]<MIN){
            MIN=a[i];
            ans += (n-(ans-i)*MIN+MIN-1)/MIN;
        }
        else ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
info = [list(map(int, input().split())) for _ in range(n)]
info.sort()
ans = 0
for i in range(n):
    if m >= info[i][1]:
        m -= info[i][1]
        ans += info[i][0]*info[i][1]
    else:
        ans += info[i][0]*m
        m = 0
    if m == 0:
        break

print(ans)

Measured memory_bytes: 27756
#include<iostream>
#include<cstdio>
#include<cmath>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long double dou;
const int N=3030;
const dou pi=acos(-1.0);
int n,L;
dou sum,t[N];
struct vec{
	dou x,y;
	vec(){}
	vec(dou _x,dou _y){x=_x,y=_y;}
	vec(dou _t){x=cos(_t),y=sin(_t);}
	vec operator + (const vec&a)const{return vec(x+a.x,y+a.y);}
	vec operator - (const vec&a)const{return vec(x-a.x,y-a.y);}
	vec operator * (const vec&a)const{return vec(x*a.x-y*a.y,x*a.y+y*a.x);}
}m,s,v,ans,a[N];
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&L);
	FOR(i,1,n){
		scanf("%Lf",&t[i]);
		t[i]*=2*pi/L;
		a[i]=vec(t[i]);
	}
	FOR(i,3,n){
		m=s=vec(0,0);
		FOR(j,1,i-1){
			v=vec((t[i]+t[j])/2);
			sum=sum+m.x;
			ans=ans+v*m+s*(a[i]-v);
			m.x++,s=s+vec(pi-(t[i]-t[j])/2);
		}
	}
	printf("%.15Lf %.15Lf",ans.x/sum,ans.y/sum);
} 

Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int main()
{
    char a[3],b[3];
    gets(a);
    gets(b);
    char ch=a[2];
    a[2]=a[0];
    a[0]=ch;
    for(int i=0;i<3;i++)
    {
        if(a[i]!=b[i])
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int ans;
    for(int i = 0; i < 5; i++){
        int tmp;
        cin >> tmp;
        if(tmp == 0){
            ans = i;
            ans++;
            break;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    println(problem97b(x))
}

fun problem97b(x: Int): Int {
    var ans = 1
    for (i in 1..x) {
        for (j in 2..x) {
            val num = Math.pow(i.toDouble(), j.toDouble())
            if (num <= x) ans = Math.max(ans, num.toInt())
        }
    }
    return ans
}

Measured memory_bytes: 29472
X, Y = [int(x) for x in input().split()]
prices = {
  3: 100000,
  2: 200000,
  1: 300000
}
totals = 0
if X in prices.keys():
  totals = totals + prices[X]
if Y in prices.keys():
  totals = totals + prices[Y]
if X == 1 and Y == 1:
  totals = totals + 400000
print(totals)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		if ("0".equals(str))
			System.out.println("1");
		else
			System.out.println("0");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

int main() {
  int64_t N;
  cin >> N;
  vector<char> Name(16);
  string answer;
  int64_t A,B;
  int counter =0;
  string X = "zabcdefghijklmnopqrstuvwxy";
  for (int i=0; ; i++){
  A = (N-1)/26;
  B = N%26;
  if (A == 0){
    Name.at(i) = X.at(B); 
    counter++;
    break;
  }
  Name.at(i) = X.at(B);
      N=A;
    counter++;
  }
 for (int i=0; i<counter; i++){
   answer += Name.at(i);
 }
  reverse(answer.begin(),answer.end());
  cout << answer << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int main(){
ll n=read(),k=read();
ll ans=1;
for (int i=2;i<=n;++i) ans*=k-1;
write(ans*k);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9+7;
const double PI = 3.14159265359;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//ctrl + /cin>>t;
	t = 1;
	while(t--){
		ll n,k;
		cin>>n>>k;
		n = n % k;
		cout<<min(n,abs(n-k));
	}
	return 0;
}
































Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

ld p[2][6];
ld calc(ld x) {
	ld sum = 0;
	rep(j, 6) {
		//ld sp = x * p[0][j] + (1 - x)*p[1][j];
		//ld lp = x * p[0][j] / sp; ld rp = 1 - lp;
		//sum += max(lp, rp)*sp;
		sum += max(x*p[0][j], (1 - x)*p[1][j]);
	}
	return sum;
}
void solve() {
	cout << fixed << setprecision(11);
	rep(i, 2) {
		rep(j, 6) {
			cin >> p[i][j]; p[i][j] /= 100.0;
		}
	}
	ld le = 0, ri = 1;
	rep(i, 500) {
		ld l = (le * 2 + ri) / 3.0, r = (le + 2 * ri) / 3.0;
		ld lc = calc(l), rc = calc(r);
		if (lc < rc) {
			ri = r;
		}
		else {
			le = l;
		}
	}
	//cout << le << endl;
	ld ans = calc(le);
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
   //cin t;
   while(t--){
        ll n;
        cin >> n;
        map < string ,  bool > m;
        int ans = 0;
        for(int i = 0 ; i < n; i ++)
        {
            string s;
            cin >> s;
            if(!m[s])
            {
                m[s] = true;
                ans ++;
            }
        }     
        cout << ans << endl;
   }
}


Measured memory_bytes: 19240
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSumOfLargeNumbers solver = new DSumOfLargeNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSumOfLargeNumbers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // K種類選ぶ時の最小は 0~ K-1の総和、つまり(k-1)k/2
            // 最大はn,n-1...n-k+1なので(2n-k+1)*k/2
            // よってつくれるのは(2n-k+1)*k/2 - (k-1)k/2 + 1

            int n = in.nextInt();
            int k = in.nextInt();
            ModInt res = new ModInt(0);
            for (int i = k; i <= n + 1; i++) {
                res = res.add((long) (2 * n - i + 1) * i / 2 - (long) (i - 1) * i / 2 + 1);
            }
            out.println(res.getVal());

        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (i + MOD) % MOD;
        }

        public ModInt add(long l) {
            return new ModInt(this.val + l);
        }

        public long getVal() {
            return val;
        }

        public String toString() {
            return Long.toString(val);
        }

    }
}



Measured memory_bytes: 40488
S = [input() for _ in range(3)]
for i in range(3):
    S[i] = list(S[i])
p = 0 #プレイヤー
while True:
    if not S[0] and p == 0:
        print("A")
        break
    if not S[1] and p == 1:
        print("B")
        break
    if not S[2] and p == 2:
        print("C")
        break
    p_t = S[p].pop(0)
    if p_t == "a":
        p = 0
    elif p_t == "b":
        p = 1
    elif p_t == "c":
        p = 2

Measured memory_bytes: 9020
#include <iostream>

int main()
{
    int sx, sy, tx, ty;
    std::cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    for(int i=0; i<dy; i++) std::cout << "U";
    for(int i=0; i<dx; i++) std::cout << "R";
    for(int i=0; i<dy; i++) std::cout << "D";
    for(int i=0; i<dx; i++) std::cout << "L";
    std::cout << "L";
    for(int i=0; i<=dy; i++) std::cout << "U";
    for(int i=0; i<=dx; i++) std::cout << "R";
    std::cout << "DR";
    for(int i=0; i<=dy; i++) std::cout << "D";
    for(int i=0; i<=dx; i++) std::cout << "L";
    std::cout << "U" << std::endl;
}

Measured memory_bytes: 256