akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main() {
  ll n;
  cin >> n;
  priority_queue<double, vector<double>, greater<double>> que;
  for (int i=0;i<n;i++){
    double v;
    cin >> v;
    que.push(v);
  }
  double ans = que.top(); que.pop();
  
  while(!que.empty()){
    double num = que.top(); que.pop();
    double sum=ans+num;
    //cout << ans << " " << num << ans+num<< endl;
    ans = sum/2.0;
    //cout << ans << endl;
  }
  cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
int n,a[N],f[N],g[N],A;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	f[1]=a[1];
	for(int i=2;i<=n;i++)
		f[i]=__gcd(f[i-1],a[i]);
	g[n]=a[n];
	for(int i=n-1;i>=1;i--)
		g[i]=__gcd(g[i+1],a[i]);
	A=max(f[n-1],g[2]);
	for(int i=2;i<n;i++)
		A=max(A,__gcd(f[i-1],g[i+1]));
	cout<<A; 
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int n, A, B, C;
vector<int> l;

int solve(int i, int a, int b, int c){
    if(i == n){
        if(a == 0 || b == 0 || c == 0) return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    int res = solve(i+1, a, b, c);
    res = min(res, solve(i+1, a+l.at(i), b, c) + (a? 10:0));
    res = min(res, solve(i+1, a, b+l.at(i), c) + (b? 10:0));
    res = min(res, solve(i+1, a, b, c+l.at(i)) + (c? 10:0));
    return res;
}

int main(){
    cin >> n >> A >> B >> C;
    l.resize(n);
    for(int i = 0; i < n; i++) cin >> l.at(i);
    cout << solve(0, 0, 0, 0) << endl;
}

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

long long int gcd(long long int S,long long int T){
  if(S % T ==0){
    return T;
  }
    return gcd(T,S%T);
}





int main(){
  long long int N,M;
  cin>>N>>M;
  char S[N+1];
  char T[M+1];
  cin>>S>>T;
  long long int A = gcd(N,M);
  int ans =0;
  for(long long int i=0;i<A;i++){
    if(S[N/A*i]!=T[M/A*i]){
      ans++;

    
    }
  }

  if(ans){
    cout<<-1;
  }
  else{
    cout<<N/A*M;
  }
  return 0;
}


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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int q, l, r, imo[114514];
bool p[114514];

signed main() {
	fill(p, p+114514, true);
	p[0] = p[1] = false;
	repst(i,2,1000) {
		if (p[i]) {
			for (int j = 2*i; j <= 100000; j += i) p[j] = false;
		}
	}
	rept(i,100100) {
		if (i%2 && p[i] && p[(i+1)/2]) imo[i]++;
		imo[i+1] += imo[i];
	}
	
	cin >> q;
	rep(i,q) {
		cin >> l >> r;
		cout << imo[r] - imo[l-1] << ln;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll D0,D1,D2,XD0,XD1,XD2,YD0,YD1,YD2,M,N;

int main() {
    cin.tie(0),ios_base::sync_with_stdio(0);
    cin >> N >> M >> D1 >> D2;
    ///
    D0 = D1*D2 / __gcd(D1,D2);
    XD0 = ((N % D0 == 0) ? (N / D0 - 1) : (N / D0));
    XD1 = ((N % D1 == 0) ? (N / D1 - 1) : (N / D1));
    XD2 = ((N % D2 == 0) ? (N / D2 - 1) : (N / D2));
    YD0 =  (M / D0);
    YD1 =  (M / D1);
    YD2 =  (M / D2);
    cout << (M - N) - ((YD1 - XD1) + (YD2 - XD2) - (YD0 - XD0)) + 1;
    return 0;
}


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

namespace insertion
{
    class Program
    {
        static void Main(string[] args)
        {
            int length = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            string ret = S;
            int hajime = 0;
            int owari = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S.Substring(i, 1) == "(") hajime++;
                else
                {
                    if (hajime != 0) hajime--;
                    else owari++;
                }
            }

            for (int i = 0; i < hajime; i++)
            {
                ret += ")";
            }

            for (int i = 0; i < owari; i++)
            {
                ret = "(" + ret;
            }
            Console.WriteLine(ret);
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 13140
//https://blog.csdn.net/qq_43765333/article/details/105489635

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int mod = 1000000007;
struct mint {
ll x; 
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
 }
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
 }
 mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
 mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
 mint inv() const {
return pow(mod-2);
 }
  mint& operator/=(const mint a) {
return (*this) *= a.inv();
 }
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
 }
};

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

ll n,k;
cin>>n>>k;

//dp[i]表示最大公约数为i的gcd(k1,k2,..,kn)的数量
mint dp[k+1],ans=0;
for(ll i=k;i>=1;i--){
    dp[i]=mint(k/i).pow(n);
    //消除重复的情况
    for(ll j=2*i;j<=k;j+=i)dp[i]-=dp[j];
    ans+=mint(i)*dp[i];
}
cout<<ans.x<<endl;
return 0;
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int count=0;
      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      String[] line = br.readLine().split(" ");
      for (int i=0; i < n; i++) {
        seq[i] = Integer.parseInt(line[i]);
      }

      count = selectionSort(seq, n);

      dispIntArray(seq);
      System.out.println(count);
    }
  }

  static int selectionSort(int a[], int n) {
    int count = 0;

    for(int i=0,min,t; i<n-1; i++ ) {
      min = i;
      for(int j=i+1; j<n; j++ ) {
        if( a[min] > a[j]) min = j;
      }
      if( min != i ) {
        t = a[i]; a[i] = a[min]; a[min] = t;
        count++;
      }
    }

    return count;
  }

  public static void dispIntArray(int a[]) {
    StringBuilder s = new StringBuilder();

    for (int i : a) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 24480
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

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

	char res;

	if (a == 'H') {
		res = b == 'H' ? 'H' : 'D';
	} else {
		res = b == 'H' ? 'D' : 'H';
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if (n * a <= b) {
      System.out.println(n * a);
    } else {
      System.out.println(b);
    }
  }
}

Measured memory_bytes: 23124
#include <stdio.h>
using namespace std;
int main()
{
	int h,n;
	int sum=0;
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++)
	{
		int temp;
		scanf("%d",&temp);
		sum+=temp;
	}
	if(sum>=h)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
using namespace std;

long long calc(long long x,long long y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

ll func(ll num){
	if(num == 1){
		return 1;
	}else{
		return num*func(num-1);
	}
}

int main(){

	ll table[26] = {0};

	char buf[41];
	scanf("%s",buf);

	for(int i = 0; buf[i] != '\0';i++){
		table[buf[i]-97]++;
	}

	ll bunshi[40],bunbo[40],index_bunshi = 0,index_bunbo = 0,sum = 0;

	int odd_num = 0;
	for(int i = 0; i <= 25; i++){
		if(table[i]%2 == 1){
			odd_num++;
			if(table[i] > 1){ //3???????????????1??????????????????????????§??????!!
				bunbo[index_bunbo] = func((table[i]-1)/2); //???????????????
				sum += (table[i]-1)/2;
				index_bunbo++;
			}
		}
		else{
			if(table[i] > 0){
				bunbo[index_bunbo] = func(table[i]/2);
				sum += table[i]/2;
				index_bunbo++;
			}
		}
	}

	if(odd_num > 1){
		printf("0\n");
		return 0;
	}

	for(int i = 0; sum-i >= 2; i++){
		bunshi[i] = sum-i;
		index_bunshi++;
	}

	ll common;

	for(int i = 0; i < index_bunshi; i++){
		for(int k = 0; k < index_bunbo; k++){
			if(bunshi[i] > bunbo[k]){
				common = calc(bunshi[i],bunbo[k]);
			}else{
				common = calc(bunbo[k],bunshi[i]);
			}
			bunshi[i] /= common;
			bunbo[k] /= common;
		}
	}

	ll ans = 1;

	for(int i = 0; i < index_bunshi;i++)ans *= bunshi[i];

	printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  vector<vi> v(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--,b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  vi used(n,-1);
  used[0]=0;
  queue<int> q;
  q.push(0);
  while(q.size()){
    int t=q.front();
    q.pop();
    rep(i,v[t].size()){
      int next=v[t][i];
      if(used[next]==-1){
	used[next]=used[t]+1;
	q.push(next);
      }else{
	if(used[next]%2==used[t]%2){
	  cout<<n*(n-1)/2-m<<endl;
	  return 0;
	}
      }
    }
  }
  vi ans(2,0);
  rep(i,n)ans[used[i]%2]++;
  cout<<ans[0]*ans[1]-m<<endl;
}


Measured memory_bytes: 7168
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n,m,d;
int main() {
    scanf("%lld%lld%lld",&n,&m,&d);
    if(d==0) printf("%.10lf",(n-d)*(m-1)*1.0/(n*n));
    else printf("%.10lf",(n-d)*(m-1)*2.0/(n*n));

    return 0;
}



Measured memory_bytes: 256
n = int(input())
nums = list(map(int,input().split(" ")))
nodes = []

class Node():
    def __init__(self,value):
        self.value = value
        self.parent = None
        self.left = None
        self.right = None

    def defineParent(self,parent):
        self.parent = parent

    def defineLeft(self,left):
        self.left = left

    def defineRight(self,right):
        self.right = right

def heapify(nums,parentIndex,root):
    leftIndex = parentIndex*2+1
    rightIndex = parentIndex*2+2
    rightFlag = False
    leftFlag = False
    if leftIndex < len(nums):
        leftNode = Node(nums[leftIndex])
        root.left = leftNode
        leftNode.parent = root
        nodes[leftIndex] = leftNode
        leftFlag = True
    if rightIndex < len(nums):
        rightNode = Node(nums[rightIndex])
        root.right = rightNode
        rightNode.parent = root
        nodes[rightIndex] = rightNode
        rightFlag = True
    if leftFlag:
        heapify(nums,leftIndex,leftNode)
    if rightFlag:
        heapify(nums,rightIndex,rightNode)

def doIt(l):
    leftIndex = 2*l+1
    rightIndex = 2*l+2
    vsNodes = [nodes[l].value]
    nextIndex = []
    if leftIndex < len(nodes):
        nextIndex.append(leftIndex)
        vsNodes.append(nodes[leftIndex].value)
    if rightIndex < len(nodes):
        nextIndex.append(rightIndex)
        vsNodes.append(nodes[rightIndex].value)
    maximumValue = max(vsNodes)
    if maximumValue > nodes[l].value:
        if maximumValue == nodes[leftIndex].value:
            changeIndex = leftIndex
        elif maximumValue == nodes[rightIndex].value:
            changeIndex = rightIndex
        tmp = nodes[l]
        nodes[l] = nodes[changeIndex]
        nodes[changeIndex] = tmp
        doIt(changeIndex)

def maxHeapify(nodes):
    startIndex = len(nodes)//2
    for l in range(startIndex,-1,-1):
        doIt(l)


nodes = [None]*len(nums)
treeRoot = Node(nums[0])
nodes[0] = treeRoot
heapify(nums,0,treeRoot)

#初期化は成功

flag = True
while flag:
    flag = maxHeapify(nodes)

ans = ""
for i in nodes:
    ans += " " + str(i.value)

print(ans)



Measured memory_bytes: 122416
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c,n;
  cin >> a >> b >> c >> n;
  ll res = 0;
  for(int i = 0;i <= a;i++){
    for(int j = 0;j <= b;j++){
      for(int k = 0;k <= c;k++){
        if(i * 500 + j * 100 + k * 50 == n)res++;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3580
//
//  main.cpp
//  test130
//
//  Created by  on 2019/06/16.
//  Copyright © 2 All rights reserved.
//
//
//  main.cpp
//  new
//
//  Created on 2019/06/09.
//  Copyright  All rights reserved.
//

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define int long long
using namespace std;

int a,ans;
vector<int> vec;
signed main(){
    cin>>a;
    if (a%2==0) {
        a/=2;
        a-=1;
    }else{
        a/=2;
    }
    
    cout<<a<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int x[n];
    for (int i = 0; i < n; i++){
        scanf("%d",&x[i]);
    }
    int best = 100000000;
    for (int i = 1; i <= 100; i++){
        int sum = 0;
        for (int j = 0; j < n; j++){
            sum += (x[j]-i)*(x[j]-i);
        }
        best = min(best,sum);
    }
    printf("%d",best);
}


Measured memory_bytes: 256
import math
A,B = map(int, input().split())

a1 = math.ceil(A / 0.08)
a2 = math.floor((A+1) / 0.08)
b1 = math.ceil(B / 0.10)
b2 = math.floor((B+1) / 0.10)

dupl = set(range(a1, a2)) & set(range(b1, b2))
if len(dupl) > 0: 
    print(min(dupl))
else:
    print(-1)



Measured memory_bytes: 9212
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
const ll MAX_N = 100000;
 
int main(void){
    ll a,b,c,d;
    string s,t;
 
    cin >> a >> b>> c;// >> d;
    //cin >> s >> t;
    if ((10*b+c)%4==0) cout << "YES";
    else cout << "NO";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */
double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int cnt=0;
   string s;cin>>s;
   for(int i=0;i+1<sz(s);++i)
   {
    if(s[i]!=s[i+1])
      cnt++;
   }
   cout<<cnt<<endl;
  
   
}



Measured memory_bytes: 512
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m>>k;
    cout<<min(n+m,min(n+k,m+k))<<endl;
}


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

int main()
{
    int n,x,f = 0;
    cin >> n;
    
    while(n!=0){
        x = n%10;
        if(x == 7) {cout << "Yes";break;}
        n /= 10;
        f++;
    }
    if(f == 3) cout << "No";
}


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

int main(){
	int n;
	while(cin >> n, n){
		int change = 1000 - n;
		int ans = 0;
		ans += change/500;
		change %= 500;
		ans += change/100;
		change %= 100;
		ans += change/50;
		change %= 50;
		ans += change/10;
		change %= 10;
		ans += change/5;
		change %= 5;
		ans += change;
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3000
#include <cstdio>
#include <cstdlib>

int N, A, B;

void solve()
{
	if(abs(A-B)%2==0) 
		printf("Alice\n");
	else
		printf("Borys\n");
}

int main()
{
	scanf("%d%d%d", &N, &A, &B);
	solve();
	return 0;
}

Measured memory_bytes: 128
A, B, C = list(map(int, input().split()))
if A == 7 and B == 5 and C == 5:
    print("YES")
elif A == 5 and B == 7 and C == 5:
    print("YES")
elif A == 5 and B == 5 and C == 7:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3316
#include <stdio.h>

int main(){
	int i,n,k,data[10000];
	for(i=2;i<10000;i++){
		data[i]=1;
	}
	for(i=2;i*i<10000;i++){
		if(data[i]==1){
			for(k=i*i;k<=10000;k+=i){
				data[k]=0;
			}
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=n;n>=3;i--){
			if(data[i]==1&&data[i-2]==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1068
import numpy as np
n = int(input())
mod = 10**9 + 7
a = np.array(list(map(int, input().split())))
ans = 0
for i in range(len(bin(max(a)))):
  num_1 = np.count_nonzero((a>>i)&1)
  num_0 = n - num_1
  ans += (2**i)*(num_1*num_0) % mod
ans %= mod
print(ans)

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

ll n, m, q;
vll a, b, c, d;
ll ans = 0;
vll seq {1};
void dfs(ll v){
  if(v == n){
    ll summ = 0;
    rep(i, 0, q) if(seq.at(b.at(i) - 1) - seq.at(a.at(i) - 1) == c.at(i)) summ += d.at(i);
    chmax(ans, summ);
    return;
  }
  rep(next, seq.at(v - 1), m + 1){
    seq.push_back(next);
    dfs(v + 1);
    seq.pop_back();
  }
  return;
}

int main(){
  cin >> n >> m >> q;
  a.assign(q, 0), b.assign(q, 0), c.assign(q, 0), d.assign(q, 0);
  rep(i, 0, q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  dfs(1);
  cout << ans << endl;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    cout << a * b / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */
int main(){
    int N; cin >> N;
    double x[N], y[N];
    int z[N];
    rep(i, N)z[i] = i;
    rep(i, N){
        cin >> x[i] >> y[i];
    }
    double sum = 0.0;
    double count = 0.0;
    do{
        rep(i, N - 1){
            sum += sqrt(pow((x[z[i]] - x[z[i + 1]]), 2) + pow((y[z[i]] - y[z[i + 1]]), 2));
        }
        ++count;
    }while(next_permutation(z, z + N));
    printf("%.6f\n", sum / count);
    //cout << sum / count << endl;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, a, b; cin>>n>>m>>a>>b;
    vector<int> x(n);
    vector<int> y(m);
    REP(i,n) cin>>x[i];
    sort(all(x),greater<int>());
    REP(i,m) cin>>y[i];
    sort(all(y));
    bool flag;
    if(b<=a){
        flag = false;
    }
    int z = a+1;
    while(1){
        if(z>b) break;
        else if(z>x[0]&&z<=y[0]){
            flag = true;
            break;
        }
        z++;
    }
    if(flag) print("No War");
    else print("War");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int p[15][15];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            p[i][j] = -1;
        }
    }

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

        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            x--;

            p[i][x] = y;
        }
    }

    int r = 0;
    for (int k = 0; k < 1 << n; k++) {
        int t = 1, m = 0;
        for (int i = 0; i < n; i++) {
            if (k >> i & 1) {
                m++;
                for (int j = 0; j < n; j++) {
                    if ((p[i][j] == 1 && !(k >> j & 1)) || (p[i][j] == 0 && (k >> j & 1))) {
                        t = 0;
                        break;
                    }
                }
            }
        }
        if (t) r = max(r, m);
    }

    cout << r << endl;

    return 0;
}

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

int main()
{   
	long long n;
	cin>>n;
	vector<pair<int,int>> factors;
	pair<int, int> u;
	u.first = 2;
    while (n % 2 == 0)  
    {  
        u.second++;
        n = n/2;  
    }  
	factors.push_back(u);
	
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        pair<int, int> u;
        u.first = i;
        while (n % i == 0)  
        {  
            u.second++;
            n = n/i;  
        }  
        factors.push_back(u);
    }  
    if (n>2){
    	factors.push_back({n, 1});
    }
    int ans = 0;
	for(auto p:factors) {
		int cnt = 0;
		long long val = pow(p.first, p.second);
		int i = 1;
		while(true){
			val = val/pow(p.first, i);
			if (val<=0) break;
			cnt++;
			i++;
		}
		ans += cnt;
	}
	
	cout<<ans<<endl;
	
	
    return 0;
}

Measured memory_bytes: 7464
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
 
int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);
 
  while(true){
    int h, w;
    cin >> h >> w;
 
    if(h==0&&w==0)
      break;
 
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
    if((i+j)%2==0)
      cout << "#";
    else
      cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3088
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s,s1,s2;
  cin >> s;
  
  int n = s.size();
  REP(i,n){
    if(i % 2 == 0){
      s1.push_back('0');
      s2.push_back('1');
    }
    else{
      s2.push_back('0');
      s1.push_back('1');
    }
  }
  
  int sum1 = 0,sum2 = 0;;
  REP(i,n){
    if(s[i] == s1[i]) sum1++;
    else if(s[i] == s2[i]) sum2++;
  }
  int ans = min(sum1,sum2);
    
  
  cout << ans << endl;
}

Measured memory_bytes: 3972
#!/usr/bin/python3

import os
import sys


def main():
    sys.setrecursionlimit(100000)
    V, E = read_ints()
    G = [set() for _ in range(V)]
    for _ in range(E):
        s, t = read_ints()
        G[s].add(t)
    print(*solve(V, E, G), sep='\n')


def solve(V, E, G):
    topo = []
    done = [False] * V

    def dfs(i):
        if done[i]:
            return
        for j in G[i]:
            dfs(j)
        done[i] = True
        topo.append(i)

    for i in range(V):
        if not done[i]:
            dfs(i)

    topo.reverse()
    return topo


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 12868
A=list(int(input()) for _ in range(5))
B=[]
C=[]
for i in A:
    if i%10!=0:
        B.append(i%10)
        C.append((i//10+1)*10)
    else:
        C.append(i)
if len(B)>0:
    c=10-min(B)
else:
    c=0
print(sum(C)-c)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();
		int n = s.length();
		String left = s.substring(0, ((n + 1) / 2) - 1);
		String right = s.substring(((n + 3) / 2) - 1, n);
		if (function(s) && function(left) && function(right)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	public static boolean function(String s) {
		int len = s.length();
		int center = len / 2;
		if (len % 2 == 0) {
			String left = s.substring(0, center);
			String right = s.substring(center, len);
			right = reverse(right);
			return left.equals(right);
		} else {
			String left = s.substring(0, center + 1);
			String right = s.substring(center, len);
			right = reverse(right);
			return left.equals(right);
		}
	}

	public static String reverse(String s) {
		int len = s.length();
		StringBuilder sb = new StringBuilder();
		String[] ss = s.split("");
		for (int i = 0; i < len; i++) {
			sb.append(ss[len - 1 - i]);
		}
		return sb.toString();
	}
}


Measured memory_bytes: 23764
n,m = map(int,input().split())
a = set([int(input())for _ in range(m)])
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2,n+1):
    if i in a:
        continue
    dp[i] = (dp[i-1]+dp[i-2])%1000000007
print(dp[n])

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

int main() {
  string S,T;
  int count=0;
  cin >>S >>T;
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i)){
      count++;
    }
  }
  cout <<count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];
  map<int, int> mp;

  ll ans = 0;
  rep(i, 0, n) {
    int sa = i - a[i];
    ans += mp[sa];
    int wa = a[i] + i;
    mp[wa]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 20952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt();
		if(a == b + c) System.out.println("Yes");
		else if(b == a + c) System.out.println("Yes");
		else if(c == a + b) System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 21844
N,M,X=map(int,input().split())

li=[]
ans=100000000000000000000000000000000

for j in range(N):
    a=list(map(int,input().split()))
    li.append(a)

for k in range(2**N):
    temp=0
    skill=[0]*M
    k=str(bin(k))
    k=k[2:]
    while len(k)!=N:
        k="0"+k
    for l in range(N):
        if k[l]=="1":
            temp+=li[l][0]
            for m in range(1,M+1):
                skill[m-1]+=li[l][m]
    if min(skill)>=X:
        if ans>temp:
            ans=temp
if ans==100000000000000000000000000000000:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9116
use proconio::input;

fn main() {
	input! {
		n: i64,
	}
	// let a: i64 = (1..=n).filter(|x| x % 3 != 0 && x % 5 != 0).sum();
	let a: i64 = (1..=n).filter(|x| x % 3 != 0 && x % 5 != 0).sum();
	println!("{}", a);
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define pii              pair <int,int>
#define debug(x) cerr << '>' << #x << ':' << x << endl;
typedef long long ll;
//#pragma comment(linker, "/STACK:667772160")
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const int MOD=1e9+7;
const int N=2*1e5+30;
const int inf = 1e17+995;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
void boostIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int prv=0,dish[55],idx[55],pons[55],ans=0;
int32_t main() {
    boostIO();
int n;
cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>idx[i];
    }
    for (int i = 0; i < n; ++i) {
        cin>>dish[i+1];
    }
    for (int i = 0; i < n - 1; ++i) {
        cin>>pons[i+1];
    }
    for (int i = 0; i < n; ++i) {
        int cur=idx[i];
        if(cur-1==prv and cur>1)ans+=pons[prv];
        ans+=dish[idx[i]];
        prv=cur;
    }
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll INF = 1e12 + 1;

ll powll(ll x, ll y){
    ll res = 1;
    REP(i,y){
        res *= x;
        if (res > INF) return INF;
    }
    return res;
}

int main(void){
    ll n;
    cin >> n;
    set<ll> st;
    for (ll x = 1; x * x <= n - 1; x++){
        if ((n - 1) % x == 0){
            st.insert(x);
            st.insert((n - 1) / x);
        }
    }
    st.insert(n);
    FOR(r,1,40){
        for (ll k = 1; k <= 1e6; k++){
            ll x = powll(k, r);
            if (x > n) break;
            ll y = x * k;
            if ((n - x) % y == 0) st.insert(k);
        }
    }
    cout << st.size() - 1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int a,b,flag=1,i=0;
	string s;
	cin >> a >> b >> s;
	for(i=0; i<a+b; i++){
		if(i==a)flag=(s[i]=='-'?1:0);
		else if(!isdigit(s[i]))flag=0;
		if(!flag)break;
	}
	cout << (flag?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define deb(x) cout << #x << ' ' << x << '\n'
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define per(i,ini) for(int i=ini;i>=0;i--)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;

ll fac[N], inv[N];

ll me(ll x, int n)
{
	ll res = 1;
	while(n)
	{
		if(n & 1)
		res = (res * x) % mod;

		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

void factorial()
{
	fac[0] = 1;
	rep(i, 1, N)
	fac[i] = (i * fac[i-1]) % mod;

	inv[N-1] = me(fac[N-1], mod-2);
	for(int i=N-1; i>0; i--)
	inv[i-1] = (i * inv[i]) % mod;
}

ll ncr(ll n, ll r)
{
	if(n < r)
	return 0;

	ll res = fac[n];
	res = (res * inv[r]) % mod;
	res = (res * inv[n-r]) % mod;
	return res;
}

int main()
{
    factorial();

    ll n, m, k;
    scanf("%lld%lld%lld", &n, &m, &k);

    ll ans = 0;

    for(int i=0; i<=k; i++)
    {
    	ll here = (m * me(m-1, n-1-i)) % mod;

    	ll ways = (here * ncr(n-1, n-1-i)) % mod;

    	ans = (ans + ways) % mod;
    }

    lprin(ans);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  
  for(int i = 0;i < N;i++){
    string x;
    cin >> x;
    
    if(x != "Y" && i < N-1) {
      continue;  
    }
    if(x == "Y" && i < N){
      cout << "Four" << endl;
      break;
    }
    if(x != "Y" && i == N-1) { 
      cout << "Three" << endl;
    }
    
    
  }
    
    

}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

int N;

void find(string cur,int mx){
	if (cur.size() == N){
		cout<<cur<<'\n';
		return;
	}
	
	FOR(i,0,mx + 1){
		find(cur + char(i+97),max((ll)mx,i));
	}
}
	
int main(){
	fast;
	
	cin>>N;
	
	find("a",0);
}



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

using namespace std;
#define mod 100000000000000000000
int main(){
    long a,b,c,d,x,y,z,r;
    cin >> a >> b >> c >> d;
    x = a*d;
    y = a*c;
    z = b*c;
    r = b*d;
    long maxx = max(x,y);
    long ans = max(maxx,z);
    long anss = max(ans,r);
    anss = anss%mod;
    cout << anss << endl;
    return 0;
}

Measured memory_bytes: 3628
defmodule Main do
  def main do
    [n, _m, x] =
      IO.gets("") |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)

    list =
      Enum.reduce(1..n, [], fn _, acc ->
        [IO.gets("") |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)] ++
          acc
      end)

    Enum.reduce(1..n, [], fn i, acc ->
      combination(list, i) ++ acc
    end)
    |> Enum.filter(&_filter(&1, x))
    |> Enum.map(&_sum/1)
    |> Enum.min(fn -> -1 end)
    |> IO.puts()
  end

  defp _filter(list_of_lists, x) do
    List.zip(list_of_lists)
    |> tl()
    |> Enum.map(fn tuple ->
      tuple |> Tuple.to_list() |> Enum.sum()
    end)
    |> Enum.all?(fn sum -> sum >= x end)
  end

  defp _sum(list_of_lists) do
    List.zip(list_of_lists) |> hd() |> Tuple.to_list() |> Enum.sum()
  end

  defp combination(_, 0), do: [[]]
  defp combination([], _), do: []

  defp combination([x | xs], n) do
    for(y <- combination(xs, n - 1), do: [x | y]) ++ combination(xs, n)
  end
end

Measured memory_bytes: 32696
N = int(input())
A = list(map(int, input().split()))

A.sort()

isWari = [True] * (10**6+1)

before = 0

for i in range(len(A)):
    if(before == A[i]):
        continue
    index = A[i]
    for j in range(index*2,10**6+1,index):
        isWari[j] = False
    before = A[i]

count = 0

for i in range(len(A)):
    if(i!=0 and A[i-1] == A[i]):
        continue
    if(i!=len(A)-1 and A[i] == A[i+1]):
        continue
    
    if(isWari[A[i]]):
        count += 1

print(count)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  vector<ll>dp1(1000001,INT_MAX);
  vector<ll>dp2(1000001,INT_MAX);
  dp1[0]=0;
  dp2[0]=0;
  for(int i=1;i<=1000;i++){
    ll w=i*(i+1)*(i+2)/6;
    if(w>1000000)break;
    for(int j=0;j<=1000000;j++){
      if(j-w>=0)dp1[j]=min(dp1[j],dp1[j-w]+1);
      if(j-w>=0&&w%2)dp2[j]=min(dp2[j],dp2[j-w]+1);
    }
  }
  int x;
  while(cin>>x){
    if(x==0)break;
    cout<<dp1[x]<<" "<<dp2[x]<<endl;
  }
  return 0;
}



Measured memory_bytes: 18200
import java.util.Scanner;

// A - Next Alphabet
// https://atcoder.jp/contests/abc151/tasks/abc151_a
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char c = scanner.next().charAt(0);
        scanner.close();

        System.out.println((char) (c + 1));
    }
}


Measured memory_bytes: 21972
from math import ceil
n,h = (int(i) for i in input().split())
a = []
b = [0]
for i in range(n):
 tmp1,tmp2= (int(i) for i in input().split())
 a.append(tmp1)
 b.append(tmp2)
a2 = sorted(a,reverse = True)
b2 = sorted(b,reverse = True)

count  = 0
while h > 0:
  if a2[0] > b2[0]:
    tmp3 = ceil(h/a2[0])
    count += tmp3
    h -= tmp3*a2[0]
  else:
    count += 1
    h -= b2[0]
    b2.pop(0)
print(count)

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> pic(h);
    for(int i = 0; i < h; i++){
        string a;
        cin >> a;
        pic[i] = "#" + a + "#";
    }
    cout << string(w+2, '#') << endl;
    for(string s : pic) cout << s << endl;
    cout << string(w+2, '#') << endl;
}

Measured memory_bytes: 3604
N,M=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
P=10**9+7
X=0
Y=0
for i in range(1,N+1):
  X+=x[i-1]*(2*i-1-N)
  X=X%P
for j in range(1,M+1):
  Y+=y[j-1]*(2*j-1-M)
  Y=Y%P
print((X*Y)%P)


Measured memory_bytes: 19580
H, W = map(int, input().split())
s_lines = [input() for i in range(H)]

def check(x, y):
	global flag
	global c
	c += 1
	if flag:
		return
	if (x < 0 or x > W-1):
		return
	if (y < 0 or y > H-1):
		return
	if c != 1:
		if s_lines[y][x] == '#':
			flag = True
			return
		elif s_lines[y][x] == '.':
			return
	check(x+1, y)#right
	check(x-1, y)#left
	check(x, y+1)#down
	check(x, y-1)#up


for y, line in enumerate(s_lines):	
	for x, l in enumerate(line):
		if l == '#':
			flag = False
			c = 0
			check(x, y)
			if flag is False:
				print('No')
				exit()
print('Yes')

Measured memory_bytes: 3064