akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define mod 1000000007
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int pr[1000007];
bool isnotprime(ll x){if(x==1)return 1;if(x==2)return 0;if(x%2==0)return 1;return(pr[x/64]&(1<<((x>>1)&31)));}
void sieve(ll n){for(ll i=3;i*i<=n;i+=2){if(!isnotprime(i))for(ll j=i*i,k=i<<1;j<n;j+=k)pr[j/64]|=(1<<((j>>1)&31));}}
ll fpow(ll x,ll y){x=x%MOD;ll res=1;while(y){if(y&1)res=res*x;res%=MOD;y=y>>1;x=x*x;x%=MOD;}return res;}
ll inv(ll a,ll m){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll n;
   cin>>n;
   ll k=2;
   ll a[n];
   for(int i=0;i<n;i++)
   cin>>a[i];
   ll dp[n];
   for(int i=0;i<n;i++)
   dp[i]=mod;
   dp[0]=0;
   for(int i=1;i<n;i++)
   {
   	for(int j=1;j<=k;j++)
   	{
   		if(i-j<0)
   		continue;
   		dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
   	}
   }
   cout<<dp[n-1];
   


}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

int main()
{
  lint a,b,k;
  cin >> a >> b >> k;

  if(a>=k){
    cout << a-k << " " << b << "\n";
  }else if(a+b>=k){
    cout << "0" << " " << b-(k-a) << "\n";
  }else{
    cout << "0 0\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int H,W;cin>>H>>W;
    vector<vector<char>>c(H,vector<char>(W));
    rep(i,H)rep(j,W){
        cin>>c.at(i).at(j);
    }
    set<int>retu;
    set<int>gyou;
    int count=0;
    rep(i,H){
        rep(j,W){
            if(c.at(i).at(j)=='#'){
                break;
            }else{
                count++;
                continue;
            }
        }
        if(count==W){
            retu.insert(i);
        }
        count=0;
    }
    rep(j,W){
        rep(i,H){
            if(c.at(i).at(j)=='#'){
                break;
            }else{
                count++;
                continue;
            }
        }
        if(count==H){
            gyou.insert(j);
        }
        count=0;
    }
    rep(i,H){
        rep(j,W){
            if(gyou.count(j) || retu.count(i)){
                continue;
            }else{
                cout<<c.at(i).at(j);
            }
        }
        if(!retu.count(i))cout<<endl;
    }
}

Measured memory_bytes: 3628
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int x1 = Integer.parseInt(sl[0]);
            int y1 = Integer.parseInt(sl[1]);
            int x2 = Integer.parseInt(sl[2]);
            int y2 = Integer.parseInt(sl[3]);

            int dx = x2 - x1;
            int dy = y2 - y1;

            int tx = x2;
            int ty = y2;
            for (int i = 0; i < 2; i++) {
                int tmp = dx;
                dx = -dy;
                dy = tmp;
                tx = tx + dx;
                ty = ty + dy;
                System.out.print(tx);
                System.out.print(" ");
                System.out.print(ty);
                if (i != 1) System.out.print(" ");
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;

int main() {

	int n;
	cin >> n;

	int a;

	int cut = 0;

	rep(i, n) {
		cin >> a;

		bool is = true;
		for(int j = 2; j <= sqrt(a); j++) {
			if (a % j == 0 && is) {
				is = false;
				break;
			}
		}

		if(is) cut++;

	}
	
	cout << cut << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
int main(){
  int n;
  cin>>n;
  int l=2;
  int r=2;
  while(r*(r-1)/2<n)
    r*=2;
  while(r-l>1){
    int h=(l+r)/2;
    if(h*(h-1)/2<n)
      l=h;
    else
      r=h;
  }
  if(r*(r-1)/2!=n){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  vector<vector<int>> s(r);
  for(int x=1,i=1;i<r;i++){
    for(int j=0;j<i;j++,x++){
      s.at(j).push_back(x);
      s.at(i).push_back(x);
    }
  }
  cout<<r<<endl;
  for(int i=0;i<r;i++){
    cout<<s.at(i).size()<<' ';
    for(int j=0;j<s.at(i).size();j++)
      cout<<s.at(i).at(j)<<(j+1<s.at(i).size()?" ":"");
    cout<<endl;
  }
}

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

string getFact(int num)
{
	if ( num % 3 == 0 ) {
		if ( num % 5 == 0 ) {
			return ("FizzBuzz");
		} else {
			return ("Fizz");
		}
	} else if ( num % 5 == 0 ) {
		return ("Buzz");
	} else {
		return (to_string(num));
	}
}

int main()
{
	int M, N;

	while ( cin >> M >> N, M || N ) {
		string S;
		int pos = 0, fail = 0;
		bool lock = false;
		bool flag[1005] = {};

		for ( int i = 0; i < N; i++ ) {
			cin >> S;
			if ( !lock ) {
				if ( S != getFact(i + 1) ) {
					flag[pos] = true;
					fail++;
				}
				if ( fail == M - 1 ) {
					lock = true;
				}
			}
			(pos += 1) %= M;
			while ( flag[pos] ) {
				(pos += 1) %= M;
			}
		}
		//out
		vector < int > ans;
		for ( int i = 0; i < M; i++ ) {
			if ( !flag[i] ) {
				ans.push_back(i + 1);
			}
		}
		cout << ans[0];
		for ( int i = 1; i < ans.size(); i++ ) {
			cout << " " << ans[i];
		}
		cout << endl;
	}

	return ( 0 );
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<ll> b(n-1);
  rep(i,n-1)cin>>b[i];
  ll s=0;
  s+=b[0];
  rep(i,n-2) {
    s+=min(b[i],b[i+1]);
  }
  s+=b[n-2];
  cout << s << endl;
  return 0;
}


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main(){

	int a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

}

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

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

    int a, b;
    cin >> a >> b;

    cout << a - (a>b) << endl;
}

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

typedef long long int lli;

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


    int n;
    cin >> n;

    vector<int> frequency(n + 1);
    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;

        frequency[x]++;
        if(x == 0 && frequency[x] == 2)
        {
            cout << 0;
            return 0;
        }

        if(frequency[x] > 2)
        {
            cout << 0;
            return 0;
        }
    }

    if(n%2 != 0)
    {
        n--;
    }

    n = n/2;
    lli product = 1;
    lli m = 1000000007;

    if(n == 0)
    {
        cout << 1 << endl;
        return 0;
    }


    while(n--)
    {
        product *= 2;
        product = product%m;
    }

    cout << product << endl;

}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <algorithm>

int n;
std::vector<int> edges[100000];

std::vector<int> path;
bool visited[100000];
bool findPath(int cur) {
	if (cur == n - 1) {
		path.push_back(n - 1);
		return true;
	}

	visited[cur] = true;

	for (auto&& e : edges[cur]) {
		if (visited[e])
			continue;

		if (findPath(e)) {
			path.push_back(cur);
			return true;
		}
	}

	return false;
}

bool used[100000];
int count(int cur) {
	used[cur] = true;

	int ret = 1;
	for (auto&& e : edges[cur])
		if (!used[e])
			ret += count(e);

	return ret;
}

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

	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		std::cin >> a >> b;
		--a, --b;

		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	findPath(0);
	std::reverse(path.begin(), path.end());
	for (auto&& e : path)
		used[e] = true;

	int a = 0, b = 0;
	for (int i = 0; i < (path.size() + 1) / 2; ++i)
		a += count(path[i]);
	for (int i = (path.size() + 1) / 2; i < path.size(); ++i)
		b += count(path[i]);

	std::cout << (a > b ? "Fennec" : "Snuke") << std::endl;
}

Measured memory_bytes: 12668
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	x := readf()
	m, i := 100.0, 0.
	for i = 0; m < x; i++ {
		m = math.Trunc(m * 1.01)
	}
	fmt.Println(i)
}

func mod(a, b float64) float64 {
	for a >= b {
		a -= b
	}
	return a
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}


Measured memory_bytes: 1856
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
long long int N, f[100][10], p[100][11],  a[10];
int func() {
	long long ans = -1000000000;
	bool flag = false;
	long long int score = 0, count[100] = {};
	for (int i = 0; i<10; i++) {
		if (a[i] == 1) flag = true;
	}
	if (flag == true) {
		for (int i = 0; i<10; i++) {
			for (int j = 0; j<N; j++) {
				if (a[i] == 1 && f[j][i] == 1)  count[j]++;
			}
		}
		for (int i = 0; i<N; i++) {
			score += p[i][count[i]];
		}
		ans = max(ans, score);
	}
	return ans;
}
long long dfs(int pos) {
	if (pos == 10) {
		
		return func();
	}
	a[pos] = 1;
	long long l, r;
	l = dfs(pos + 1);
	a[pos] = 0;
	r = dfs(pos + 1);
	return max(l, r);
}

int main() {
	cin >> N;
	for (int i = 0; i<N; i++) {
		for (int j = 0; j<10; j++)   cin >> f[i][j];
	}
	for (int i = 0; i<N; i++) {
		for (int j = 0; j<11; j++)   cin >> p[i][j];
	}
	
	cout << dfs(0) << endl;
	return 0;
}

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

public class Main {
	
	public static boolean[] sieve (int n) {
		
		boolean[] isPrime = new boolean[n];
		Arrays.fill(isPrime, true);
		
		int lim = (int)Math.sqrt(n);
		
		for (int i = 4; i < isPrime.length; i += 2)
			isPrime[i] = false;
		for (int i = 3; i <= lim; i += 2) {
			for (int j = 3; i * j < isPrime.length; j += 2)
				isPrime[i * j] = false;
		}
		
		return isPrime;
		
	}
	
	public static int solve (int n) {
		
		int cnt = 0;
		boolean[] prime = sieve(n);
		
		if (prime[n - 2]) cnt++;
		
		for (int i = 3; i <= n / 2; i += 2) {
			if (!prime[i]) continue;
			if (prime[n - i]) {
				cnt++;
			}
			
		}
		
		return cnt;
	}
	
	public static void main (String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			
			int num = Integer.parseInt(br.readLine());
			
			if (num == 0) break;
			
			System.out.println(solve(num));
			
		}
		
	}
}

Measured memory_bytes: 11000
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 

    char a[3][3];
    REP(i,3)REP(j,3){
        cin>>a[i][j];
    }
    cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
	std::string str;
	std::cin >> str;

	for (int i = 0; i < str.size(); i++) {
		if (str[i] >= 'G' && str[i] <= 'Z') {
			str[i] = str[i] - 3;
			std::cout << str[i];
		}
		else if (str[i] == 'D') {
			std::cout << 'A';
		}
		else if (str[i] == 'E') {
			std::cout << 'B';
		}
		else if (str[i] == 'F') {
			std::cout << 'C';
		}
		else if (str[i] == 'D') {
			std::cout << 'A';
		}
		else if (str[i] == 'A') {
			std::cout << 'X';
		}
		else if (str[i] == 'B') {
			std::cout << 'Y';
		}
		else if (str[i] == 'C') {
			std::cout << 'Z';
		}
	}
	std::cout << std::endl;
	return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define int long long int

signed main() {
  int n, i, j, k;
  vector<int> a(10010, 0);
  while(cin >> n) {
    vector<int> ans(4, 1000010001);
      for(i = 0; i < n; i++) {
	cin >> a[i];
      }
    for(i = 0; i < n; i++) {
      for(j = 0; j < n; j++) {
	if(i == j) continue;
	int temp = a[j];
	for(k = 0; temp > 0; k++) temp/=10;
	ans[3] = a[i]*pow(10, k) + a[j];
	sort(ans.begin(), ans.begin() + 4);
      }
    }
    cout << ans[2] << endl;
  }
  return 0;
}

Measured memory_bytes: 1332
'use strict'
const main = input => {
  const n = parseInt(input[0], 0), p = input[1].split(' ').map(val => parseInt(val, 10));
  // console.log(n, p);
  let miss = 0;
  for(let i=0; i<n; i++) {
    if (p[i] != i+1) miss++ 
  }
  console.log(miss<=2?'YES':'NO');
  // console.log(miss);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

int main(){
  int n_max,n_min,m;
  while(cin >> m >> n_min >> n_max,m!=0){
    vector<int> v;
    int m_gyap=0;
    int ans;
    
    for(int i=0; i<m; ++i){
      int tmp;
      cin >> tmp;
      v.push_back(tmp);
    }

    for(int i=n_min-1; i<n_max; ++i){
      int tmp;
      tmp = v[i] - v[i+1];
      if(m_gyap <= tmp){
	m_gyap = tmp;
	ans = i+1;
	//cout << "gyap is " << v[i] << " to " << v[i+1] << endl;
      }
    }

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


Measured memory_bytes: 3160
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/02/20 20:55:48
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int k; cin>>k;
  if (gcd(k, 10) != 1) {
    cout << -1 << endl;
  } else {
    const int MOD = k%7 == 0 ? 9*k/7 : 9*k;
    int ans = 1;
    int m = 10;
    while (m % MOD != 1) {
      m = m*10 % MOD;
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
int ans[1000][1000];
int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	for (int i = 0; i < B; i++) {
		for (int j = 0; j < A; j++) ans[i][j] = 1;
	}
	for (int i = B; i < H; i++) {
		for (int j = A; j < W; j++) ans[i][j] = 1;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cout << ans[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
deque < int > a;
int all=0;
int ans=0;
int main()
{
	int n,k;
	cin>>n>>k;
	int j;
	for(int i=0;i<n;i++)
	{
		cin>>j;
		all+=j;
		a.push_back(j);
	}
	int k2=k*4;
	bool m=0;
	if(all%k2)
		m=1;
	all=all/k2;
	for(int i=0;i<n;i++)
	{
		if(all<a[i])
			ans++;
		else if(all==a[i]&&m==0)
			ans++;
	}
	if(ans>=k)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

using namespace std;

int main() {
  int N;
  vector<long> seq;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    long c_seq;
    
    cin >> c_seq;
    
    seq.push_back(c_seq);
  }
  // 此れに尽きる
  sort(seq.begin(), seq.end());
  
  bool isDuplicated = false;
  
  // 狭義単調増加が云えれば良いので全探索
  for (int i = 1; i < N; i++) {
    if (seq.at(i) == seq.at(i - 1)) {
      isDuplicated = true;
    }
  }
  
  if (isDuplicated) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  
  return 0;
}

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

typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;

#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define all(v) v.begin(), v.end()
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define T ll t; cin>>t; while(t--)

int main(){
  FAST

  ll n,s=0;
  cin>>n;
  rep(i,1,n+1){
  	rep(j,1,n+1){
    	rep(l,1,n+1)
          s+=__gcd(i,__gcd(j,l));
    }
  }
  
  cout<<s;
  return 0;
}







Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
  int n,m;
  double S;
  string ans="No";
	cin >> n >> m;
    vector<int> A(n);
  for(int& e: A)cin >> e;
  sort(A.begin(), A.end()); 
  reverse(A.begin(), A.end());
  S = (double)accumulate(A.begin(), A.end(),0)/(double)(4*m);
  
  if(A[m-1] >= S) ans="Yes";     
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    ll n;
    cin >> n;
    int input1[n],input2[n];
    rep0(i,n){
        cin >> input1[i];
    }
    rep0(i,n){
        cin >> input2[i];
    }
    ll res=0;
    rep0(i,n){
        if(input1[i]-input2[i]>0){
            res+=input1[i]-input2[i];
        }
    }
    cout << res;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp;
    map<ll, ll> count;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        if (!mp[a[i]]) {
            mp[a[i]] = i + 1;
        } else {
            mp[a[i]] = min(mp[a[i]], i + 1);
        }
        count[a[i]]++;
    }
    sort(all(a), greater<ll>());
    a.erase(unique(a.begin(), a.end()), a.end());
    a.push_back(0);
    vector<ll> ans(n + 1, 0);
    for (int i = 0; i < a.size() - 1; i++) {
        ans[mp[a[i]]] += (a[i] - a[i + 1]) * count[a[i]];
        mp[a[i + 1]] = min(mp[a[i + 1]], mp[a[i]]);
        count[a[i + 1]] += count[a[i]];
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i + 1] << endl;
    }
}


Measured memory_bytes: 15104
#include<stdio.h>

int main(){
	int n,i;
	scanf("%d",&n);
	
	long long res = 0;
	int max = 0;
	int x;
	for(i = 0;i < n;i++){
		scanf("%d",&x);
		if(x > max)
			max = x;
		
		res += max - x;
	}
	
	printf("%lld",res);
}

Measured memory_bytes: 1732
n,k = map(int,input().split())
s = input()
s = list(s)
if s[k-1] == 'A':
  s[k-1] = 'a'
elif s[k-1] == 'B':
  s[k-1] = 'b'
else:
  s[k-1] = 'c'
print(''.join(s))

Measured memory_bytes: 3060
while True:
    (H,W) = [int(x) for x in input().split()]
    if H == W == 0:
        break

    for hc in range(H):
        for wc in range(W):
            if(hc + wc) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

Measured memory_bytes: 6808
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int x,y; cin >> x >> y;

    //int res=1+floor(log2(y)-log2(x));
    //int res=1+(log2(y)-log2(x));
    int res=0;
    while(x<=y){
        x*=2;
        res++;
    }
    cout<<res<<endl;
    
}

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

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

Measured memory_bytes: 256
import math

N, A, B = map(int, input().split())
V = list(map(int, input().split()))

# print(N, A, B, V)

V.sort(reverse=True)

max_list = V[:A]
max_sum = sum(max_list)
print(max_sum / A)

replace = max_list[-1]

num_replace = 0
for v in V:
    if v == replace:
        num_replace += 1

if num_replace == 1:
    print(1)
    exit()

num_replace_in_list = 0
for v in max_list:
    if v == replace:
        num_replace_in_list += 1

if replace * A != max_sum:
    ans = math.factorial(num_replace) // (math.factorial(num_replace - num_replace_in_list) * math.factorial(num_replace_in_list))
    print(ans)
    exit()


ans = 0
for i in range(A, B + 1):
    if i > num_replace:
        break
    ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))

print(ans)


Measured memory_bytes: 38640
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

use std::time::Instant;
fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums = HashMap::with_capacity(n + 1);
    for &a in &aa {
        *nums.entry(a).or_insert(0) += 1;
    }
    // let mut nums: HashMap<_, i32> = aa.iter()
    //     .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: BTreeSet<_> = (0..n + 1).collect();
    let mut r2: HashSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    let mut cnt = 1;
    while !rems.is_empty() {
        while let Some(s_idx) = q.pop_front() {
            r2.remove(&s_idx);
            if !rems.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            if let Some(destv) = dests.remove(&s_num) {
                for dest in destv {
                    q.push_back(dest);
                }
            }
        }
        if let Some(&rem) = r2.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
        if let Some(&r) = rems.iter().next() {
            // q.push_back(r);
            cnt += r;
        }
    }
    if cnt > 1e18 as usize{
        println!("{}", "hoge");
    }
    println!("{}", ans);
}


Measured memory_bytes: 27576
N = int(input())
A = [0]*(N+1)
for i in range(1, N+1):
    A[i] = int(input())
B = [0, 1]+[0]*(N-1)
ans = 0
i = 1
while B[i]:
    ans += 1
    if i == A[i] or B[A[i]] == 1:
        break
    elif A[i] == 2:
        print(ans)
        exit()
    else:
        i = A[i]
        B[i] = 1
print(-1)


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

int main()
{
  string s;
  cin >> s;
  int res = 0, cnt = 0;
  
  for(int i=0; i<s.size(); i++)
  {
    if(s[i] == 'A' ||
      s[i] == 'C' ||
      s[i] == 'G' ||
      s[i] == 'T')
    {
      cnt++;
    }
    else
    {
      res = max(res, cnt);
      cnt = 0;
    }
  }
  
  res = max(res, cnt);
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3616
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

template<typename T>
vector<ll> countVector(vector< T >v,T guard=-1){
    ll size=v.size();
    //番兵を追加(初期値は-1)
    v.push_back(guard);
    vector<ll>ret;
    ll count=1;
    for(int i=0;i<size;i++){
        if(v[i]==v[i+1]){
            count++;
        }else{
            ret.push_back(count);
            count=1;
        }
    }
    return ret;
}

int main(){
  init();
  ll r;cin>>r;
  cout<<3*r*r<<endl;
}


Measured memory_bytes: 256
import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        X,Y = map(int, self.input_data().split())
        if Y >= X * 2 and Y % 2 == 0 and Y <= X * 4:
            print('Yes')
        else:
            print('No')


solver = Solver(REL_PATH)
solver.exec_resolve()


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

using namespace std;

#define ll long long

#define DEBUG (0)

int main()
{
  ll N = 0;
  cin >> N;
  ll count = 0;

  for(ll i = 1 ; i <= N; i++){
    if((i%3 != 0) && (i%5 != 0)){
      count += i;
    }
  }

  cout << count << "\n";
}


Measured memory_bytes: 3672
n=int(input())
list_num = [3, 5, 7]
result=[]
def dfs(val):
  if val > n:
    return

  result.append(val)

  for i in list_num:
    dfs(val*10+i)

dfs(0)
count = 0
for i in result:
  str_num = str(i)

  if str_num.count('3') == 0:
    continue
  if str_num.count('5') == 0:
    continue
  if str_num.count('7') == 0:
    continue
  count += 1

print(count)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  string s, t;
  cin >> s >> t;
  int q;
  cin >> q;
  vector<int> sum1(s.size() + 1, 0);
  vector<int> sum2(t.size() + 1, 0);
  // -- Note by MoSooN --
  // all s is transformed into A or AA or AAA
  // transform is inversible so seek substring of s ,t  is which of them. if same Yes not No
  // -- End note  --
  for (int i = 0; i < s.size(); i++)
  {
    sum1[i + 1] = sum1[i] + (s[i] == 'A') + 1;
  }
  for (int i = 0; i < t.size(); i++)
  {
    sum2[i + 1] = sum2[i] + (t[i] == 'A') + 1;
  }
  for (int i = 0; i < q; i++)
  {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    c--;
    if ((sum1[b] - sum1[a]) % 3 == (sum2[d] - sum2[c]) % 3)
    {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
  }

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 5036
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin>>N;
    cin>>S;
    int ans=0;
    for(int k=0;k<1000;k++){
        int m=k;
        string now;
        for(int i=0;i<3;i++){
            now+='0'+m%10;
            m/=10;
        }
        int icchi=0;
        int flag=0;
        for(int i=0;i<N;i++){
            if(flag){
                break;
            }
            if(S[i]==now[icchi]){
                icchi++;
                if(icchi==3){
                    flag=1;
                }
                continue;
            }
            
        }
        if(icchi==3){
            ans++;
        }
    }
    cout<<ans<<endl;

}

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

if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    if (b - 1) < (n - a):
        print((a - 1)+((b - a + 1)//2))
    else:
        print((n - b) + (b - a + 1)//2 )

Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int result = 0;
        int kari = 0;
        for(int i = 0;i<s.length();i++){
            if(i%2==0 && s.charAt(i) == '0'){
                kari++;
            }else if(i%2==1 && s.charAt(i) == '1'){
                kari++;
            }
        }
        for(int i = 0;i<s.length();i++){
            if(i%2==0 && s.charAt(i) == '1'){
                result++;
            }else if(i%2==1 && s.charAt(i) == '0'){
                result++;
            }
        }
        if(kari<result){result = kari;}
        System.out.println(result);
        sc.close();
    }
}

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

int grid[2020][2020];

int main(){
	int X,Y,W,H;	cin>>X>>Y>>W>>H;
	int ans=W*H;
	for(int j=0;j<H;j++){
		for(int k=0;k<W;k++){
			grid[Y+j][X+k]=1;
		}
	}

	cin>>X>>Y>>W>>H;
	ans+=W*H;
	for(int j=0;j<H;j++){
		for(int k=0;k<W;k++){
			++grid[Y+j][X+k];
			if(grid[Y+j][X+k]==2)ans-=2;
		}
	}
	if(ans<0)ans=0;
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 18896
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k;
int arr[51];
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for(int i =0 ; i < n; i ++){
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int ret =0 ;
    for(int i = n - 1; i >= 0; i --){
        if(k == 0)break;
        k --;
        ret += arr[i];
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;

namespace ALDS1_8_B {
    class Node {
        public int Key { get; set; }
        public Node Parent { get; set; }
        public Node Left { get; set; }
        public Node Right { get; set; }

        public Node(int key = default(int), Node parent = null) {
            Key = key;
            Parent = parent;
        }

        public Node(Node node) {
            this.Key = node.Key;
            this.Parent = node.Parent;
            this.Left = node.Left;
            this.Right = node.Right;
        }
    }

    class Problem {
        private Node _root;
        private StringBuilder _sb;

        public void Run() {
            _sb = new StringBuilder();
            int n = int.Parse(Console.ReadLine());
            SetRoot();
            for (int i = 1; i < n; i++) {
                string[] input = Console.ReadLine().Split(' ');

                switch (input[0]) {
                    case "insert":
                        Insert(int.Parse(input[1]));
                        break;
                    case "print":
                        Inorder(_root);
                        _sb.AppendLine();
                        Preorder(_root);
                        _sb.AppendLine();
                        break;
                    case "find":
                        _sb.AppendLine(Find(int.Parse(input[1])) != null ? "yes" : "no");
                        break;
                }
            }
            Console.Write(_sb);
        }

        private Node Find(int key) {
            Node ret = new Node(_root);
            while (ret != null && key != ret.Key) {
                ret = key < ret.Key ? ret.Left : ret.Right;
            }
            return ret;
        }
        
        private void Insert(int key) {
            if (_root == null) {
                _root = new Node(key);
                return;
            }

            Node x = _root;
            Node y = null;
            while (x != null) {
                y = x;
                x = key < x.Key ? x.Left : x.Right;
            }

            if (key < y.Key)
                y.Left = new Node(key, parent: y);
            else
                y.Right = new Node(key, parent: y);
        }

        private void Inorder(Node node) {
            if (node == null)
                return;
            Inorder(node.Left);
            _sb.Append(" " + node.Key);
            Inorder(node.Right);
        }

        private void Preorder(Node node) {
            if (node == null)
                return;
            _sb.Append(" " + node.Key);
            Preorder(node.Left);
            Preorder(node.Right);
        }
        
        private void SetRoot() {
            string[] input = Console.ReadLine().Split(' ');
            _root = new Node(int.Parse(input[1]));
        }
    }

    class Program {
        static void Main(string[] args) {
            Problem p = new Problem();
            p.Run();
        }
    }
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (a <= b) {
    cout << a << endl;
  } else {
    cout << a - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#define lson i<<1
#define rson i<<1|1
#define up(i,x,y) for(i=x;i<=y;i++)
#define down(i,x,y) for(i=x;i>=y;i--)
#define mem(a,x) memset(a,x,sizeof(a))
#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d%d",&x,&y)
#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld%lld",&x,&y)
#define gc(x) scanf("%c",&x)
#define gc2(x,y) scanf("%c%c",&x,&y)
using namespace std;
const double eps=1e-8; 
typedef long long ll;
const double PI = acos(-1.0); 
const int MAXN=100005;
const ll mod=1e7+9;
const ll llinf = (ll)(1e18) + 500;
const int inf=0x3f3f3f3f;
ll n, n2;
vector<ll>di,zhi;
int cnt=0;
vector<ll>divisor;
void init(){
	n2 = n;
	if(n < 2)return ;                //小于2的数不合法，若n为质数则输出它本身
	for(ll i = 2; i*i <= n2; i++)        //根号n复杂度
	{
		if(n2%i==0){
			int cnt=0;
			di.push_back(i);
			while (n2%i == 0){
				n2 = n2 / i;
				cnt++;
			}
			zhi.push_back(cnt);
		}
	}
	if(n2!= 1){
		di.push_back(n2);
		zhi.push_back(1LL);
	}
	return ;
}
vector<ll>tmp,tmp1;
ll npow(ll a,int b){
	ll num=1;while(b--){
		num*=a;
	}
	return num;
}
void dfs(int cur,ll k,int z){
	if(cur==tmp.size()){
		if(k==1)return;
		ll t=n/npow(k,z)-1;
		if(t%k==0){cnt++;}
		return;
	}
	dfs(cur+1,k,z);
	for(int i=1;i<=tmp1[cur];i++){
		dfs(cur+1,k*tmp[cur],z);
		k*=tmp[cur];
	}
}
int main()
{
	
	cin >> n;
	init();
//	for(int i=0;i<zhi.size();i++){
//		cout<<di[i]<<' '<<zhi[i]<<endl;
//	}
	n--;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			if(n/i==i){
				cnt++;
			}
			else{
				cnt+=2;
			}
		}
	}
	cnt--;n++;
	ll maxn=0;
	for(int i=0;i<zhi.size();i++){
		maxn=max(maxn,zhi[i]);
	}
	for(int i=1;i<=maxn;i++){
		tmp.clear();
		tmp1.clear();
		for(int j=0;j<zhi.size();j++){
			if(zhi[j]>=i){
				tmp.push_back(di[j]);
				tmp1.push_back(zhi[j]/i);
			}
		}
		dfs(0,1,i);
	}
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a,A[100],i,j,flag=1,chan=0,count=0;
  scanf("%d",&a);
  for(i=0;i<a;i++)scanf("%d",&A[i]);
  for(i=0;i<a;i++)
    {
      for(j=a-1;j>=1;j--)
	{
	  if( A[j] < A[j-1])
	    {
	      chan=A[j];
	      A[j]=A[j-1];
	      A[j-1]=chan;
	      count++;
	    }
	}
    }
  for(i=0;i<a;i++){
    printf("%d",A[i]);
    if(i!=a-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2108
main :: IO ()
main = do
    [_,_,xx,yy] <- map read . words <$> getLine :: IO [Int]
    x <- map read . words <$> getLine :: IO [Int]
    y <- map read . words <$> getLine :: IO [Int]
    let mx = maximum x
        my = minimum y
        n  = length [ z | z <- [(xx+1)..yy], mx < z && my >= z]
    putStrLn $ if n == 0 then "War" else "No War"


Measured memory_bytes: 1020
N, K = map(int, input().split())
D = list(input().split())

for i in range(N, 1000000):
    tmp = list(str(i))
    count = 0
    for j in range(len(tmp)):
        if tmp[j] not in D:
            count += 1
    if count == len(tmp):
        ans = ''.join(tmp)
        break

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long int a;
	cin >> a;
	for(long int h=1;h<3501;h++){
		for(long int n=1;n<3501;n++){
			long int x = 4*h*n-a*n-a*h;
			long int y = a*h*n;
			if(x>0 && y>=x && y%x==0){
				long int w = y/x;
				cout << h << ' ' << n << ' ' << w << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, R;
	cin >> N >> R;

	cout << R + 100 * max(0, 10 - N) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    int dp[n];
    rep(i,n) cin >> h[i];
    for(int i=0;i<n;++i){
        if(i==0) dp[i]=0;
        else if(i==1)dp[i]=abs(h[i]-h[i-1]);
        else dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
    }
    cout << dp[n-1]<<endl;
    return 0;
    }

Measured memory_bytes: 1024
import java.util.*

//

fun main() {
    abc167c()
}

fun abc167c() {
    val (n, m, x) = readLine()!!.split(" ").map { it.toInt() }
    val books = mutableListOf<Book>()
    val sc = Scanner(System.`in`)
    for (i in 0 until n) {
        val c = sc.nextInt()
        val e = mutableListOf<Int>()
        for (j in 0 until m) {
            e.add(sc.nextInt())
        }
        books.add(Book(c, e))
    }
    val cost = 1000000
    val pattern = mutableListOf<Book>()
    val emptyBook = Book(0, List<Int>(m) { 0 })
    generatePattern(books, pattern, emptyBook, 0, x)
    if (pattern.isEmpty()) {
        println("-1")
    } else {
        val min = pattern.minBy { it.cost }
        println(min!!.cost)
    }
}

fun generatePattern(data: List<Book>, result: MutableList<Book>, current: Book,
    num: Int, x: Int) {
    if (num == data.size) {
        val ng = current.experience.filter { it < x }
        if (ng.isEmpty()) {
            result.add(current)
        }
    } else {
        generatePattern(data, result, current, num + 1, x)
        val t = data[num]
        val e = current.experience.mapIndexed { index, i -> t.experience[index] + i }
        generatePattern(data, result, Book(t.cost + current.cost, e), num + 1, x)
    }
}

data class Book(
    val cost: Int,
    val experience: List<Int>
)

Measured memory_bytes: 43040