akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

class Stack{
    private:
        int now;
        int num[10010];
    public:
        Stack(){
            now=-1;
        }
        void push(int x)
        {
            now++;
            num[now]=x;
        }
        int take()
        {
            int x=num[now];
            now--;
            return x;
        }
};

int main()
{
    Stack stack;
    string s;int x,y;
    while(cin>>s)
    {
        if(s=="+")
        {
            x=stack.take();
            y=stack.take();
            stack.push(y+x);
        }
        else if(s=="-")
        {
            x=stack.take();
            y=stack.take();
            stack.push(y-x);
        }
        else if(s=="*")
        {
            x=stack.take();
            y=stack.take();
            stack.push(y*x);
        }
        else 
        {
            x=atoi(s.c_str());
            stack.push(x);
        }
    }
    cout<<stack.take()<<endl;
}


Measured memory_bytes: 3216
# -*- coding: utf-8 -*-
i_str = input()
A,B = map(int,i_str.split())
import sys
import math
#price = 10
#X = math.floor(price * 0.08)
#Y = math.floor(price*0.1)

if A > B:
    print(-1)

for i in range(B*100):
    if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
        print(i)
        sys.exit()
print(-1)


Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 左括弧 */
	private static final char LEFT = '(';

	/** 右括弧 */
	private static final char RIGHT = ')';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			// n
			scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			// 現在までの閉じていない左括弧と右括弧の数
			int noRight = 0, noLeft = 0;
			for (char c : s) {
				if (LEFT == c) {
					if (noRight >= 0) {
						noRight++;
					} else {
						noLeft -= noRight;
						noRight = 1;
					}
				} else {
					noRight--;
				}
			}
			if (noRight < 0) {
				noLeft -= noRight;
				noRight = 0;
			}
			System.out.println(repeat(LEFT, noLeft) + String.valueOf(s) + repeat(RIGHT, noRight));
		}
	}

	/**
	 * @param c 文字
	 * @param n 数
	 * @return 文字をn回繰り返した文字列
	 */
	private static String repeat(char c, int n) {
		StringBuilder sb = new StringBuilder();
		IntStream.range(0, n).forEach(i -> sb.append(c));
		return sb.toString();
	}
}


Measured memory_bytes: 39720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();

        int total = 0;
        int min = 1001;
        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            min = Math.min(m, min);
            total++;
            x -= m;
        }

        total += x / min;

        System.out.println(total);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int arr[100005][3]={0};
int dp[100005][3]={0};
bool is_completed[100005][3]={0};
bool check(int a , int b)
{
    for(int i=0;i<3;i++)
    {
        if(i!=b)
        {
            if(is_completed[a][i]==false)
                return false;
        }
    }
    return true;
}
int dynamic(int a ,int b)
{
    int ma=0;
    if(a==1)
    {
        is_completed[a][b]=true;
        for(int i=0;i<3;i++)
        {
            if(i!=b)
            {
                if(ma<dp[a-1][i])
                {
                    ma=dp[a-1][i];
                }
            }
        }
        dp[a][b]=arr[a][b]+ma;
        return dp[a][b];
    }
    else if(is_completed[a][b]==true)
    {
        return dp[a][b];
    }
    /*else if(check(a-1,b))
    {
        is_completed[a][b]=true;
        for(int i=0;i<3;i++)
        {
            if(i!=b)
            {
                if(ma<dp[a-1][i])
                {
                    ma=dp[a-1][i];
                }
            }
        }
        dp[a][b]=arr[a][b]+ma;
        return dp[a][b];
    }*/
    else
    {
        is_completed[a][b]=true;
        for(int i=0;i<3;i++)
        {
            int c=0;
            if(i!=b)
            {
                c=dynamic(a-1,i);
                if(ma<c)
                    ma=c;
            }
        }
        dp[a][b]=ma+arr[a][b];
        return dp[a][b];
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0;i<3;i++)
    {
        dp[0][i]=arr[0][i];
    }
    is_completed[0][0]=is_completed[0][1]=is_completed[0][2]=true;
    int ma=dynamic(n-1,0);
    int ma1=dynamic(n-1,1);
    int ma2=dynamic(n-1,2);
    //cout<<ma<<" "<<ma1<<" "<<ma2<<" ";
    ma=max(ma,ma1);
    ma=max(ma,ma2);
    cout<<ma<<"\n";
    /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cout<<dp[i][j]<<"\n";
        }
        cout<<"\n";
    }*/
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

int main() {
  int k, t;
  cin >> k >> t;
  vector<int> a(t);
  rep(i, t) cin >> a[i];
  int a_max = *max_element(a.begin(), a.end());
  int ans = 0;
  rep(i, k) {
    if(a_max <= 1 + i + (k - 1 - i) / 2) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

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

	int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << ans << endl;
	return 0;
}


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

int main() {
	int N;
	std::cin >> N;
	
	std::string S;
	std::cin >> S;

	int max = 0;

	for(int i = 1; i < N; i++) {
		std::string a, b;
		a = S.substr(0, i);
		b = S.substr(i, S.length() - i);
		int num = 0;
		for(char ch = 'a'; ch <= 'z'; ch++) {
			if(a.find(ch) != a.npos && b.find(ch) != b.npos) {
				num++;
			}
		}
		if(num > max) {
			max = num;
		}
	}

	std::cout << max << std::endl;

	return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  if (X%Y==0) {
    cout << -1 << endl;
  }
  else {
    cout << X << endl;
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long
#define PB push_back
#define INF 1000000000

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

	if(x==3 || x==5 || x==7)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <limits>
#include <vector>

template <class Monoid>
struct SegmentTree {
  using T = typename Monoid::type;
  int N_, N;
  std::vector<T> dat;

  SegmentTree(const int N_) : N_(N_) {
    assert(N_ > 0);
    N = 1;
    while (N < N_) {
      N <<= 1;
    }
    dat.assign(2 * N - 1, Monoid::identity());
  }

  SegmentTree(const std::vector<T> &dat_) : N_(dat_.size()) {
    assert(N_ > 0);
    N = 1;
    while (N < N_) {
      N <<= 1;
    }
    dat.assign(2 * N - 1, Monoid::identity());
    std::copy(dat_.begin(), dat_.end(), dat.begin() + N - 1);
    for (int i = N - 2; i >= 0; i--) {
      dat[i] = Monoid::merge(dat[2 * i + 1], dat[2 * i + 2]);
    }
  }

  int size() { return N_; }

  void update(int key, T val) {
    assert(0 <= key && key < N_);

    key += N - 1;
    dat[key] = val;

    while (key > 0) {
      key = (key - 1) / 2;
      dat[key] =
          Monoid::merge(dat[2 * key + 1], dat[2 * key + 2]);  // rewrite here
    }
  }

  // [a, b)
  T query(int low, int high) {
    assert(0 <= low && low <= high && high <= N_);
    return query(low, high, 0, 0, N);
  }

  T query(int low, int high, int key, int left, int right) {
    low += N, high += N;
    T ret = Monoid::identity();
    while (low < high) {
      if (low & 1) {
        ret = Monoid::merge(ret, dat[low - 1]);
        low++;
      }
      if (high & 1) {
        high--;
        ret = Monoid::merge(ret, dat[high - 1]);
      }
      low >>= 1, high >>= 1;
    }
    return ret;
  }
};

template <typename T>
struct RangeSumQuery {
  using type = T;
  static type identity() { return T(0); }
  static type merge(const type &l, const type &r) { return l + r; }
};

template <typename T>
struct RangeMinQuery {
  using type = T;
  static type identity() { return std::numeric_limits<T>::max(); }
  static type merge(const type &l, const type &r) { return std::min(l, r); }
};

template <typename T>
struct RangeMaxQuery {
  using type = T;
  static type identity() { return T(0); }
  static type merge(const type &l, const type &r) { return std::max(l, r); }
};

void aoj() {
  // https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_A
  int N, Q;
  std::cin >> N >> Q;
  SegmentTree<RangeMinQuery<int>> rmq(N);
  for (int i = 0; i < Q; i++) {
    int t, x, y;
    std::cin >> t >> x >> y;
    if (t == 0) {
      rmq.update(x, y);
    } else {
      std::cout << rmq.query(x, y + 1) << '\n';
    }
  }
}

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  aoj();
  return 0;
}


Measured memory_bytes: 3864
n = int(input())
ngoList = list(map(lambda x:int(x),input().split()))
ans = 0
count = 0
for i in range(n-1):
    if ngoList[i] >= ngoList[i+1]:
        count += 1
    else:
        ans = max(ans,count)
        count = 0
print(max(ans,count))

Measured memory_bytes: 14224
k, n = map(int, input().split())
a = list(map(int, input().split()))

length = [0 for _ in range(n)]
length[0] = a[0] + k - a[-1]
for i in range(1, n):
    length[i] = a[i] - a[i-1]
print(sum(length) - max(length))


Measured memory_bytes: 26060
#include<bits/stdc++.h>
using namespace std;
int main()
{
int fly[]={4,1,4,1,2,1,2,1},peo[8],remainder,point;
while(cin>>peo[0]){
for(int i=1;i<8;i++)cin>>peo[i];
for(int i=0;i<8;i++){
int num=0;
for(int j=0;j<8;j++)if(fly[(i+j)%8]<peo[j])num+=peo[j]-fly[(i+j)%8];
if(remainder>num||i==0){
remainder=num;
point=i;
}
else if(remainder==num){
for(int j=0;j<8&&fly[(i+j)%8]<=fly[(point+j)%8];j++){
if(fly[(i+j)%8]<fly[(point+j)%8]){
point=i;
break;
}
}
}
}
for(int i=0;i<7;i++)cout<<fly[(point+i)%8]<<" ";
cout<<fly[(point+7)%8]<<endl;
}
}

Measured memory_bytes: 1160
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main() {
    ll n,k;
    string s;
    std::cin >> n>>k;
    std::cin >> s;
    vector<pair<ll,ll>> v;
    ll now = s[0]-'0';
    ll now_count = 1;
    for (int i = 1; i < s.length(); i++) {
        if(s[i]-'0'==now){
            now_count++;
            if(i==s.length()-1){
                v.push_back({now,now_count});
            }
        }else{
            v.push_back({now,now_count});
            now = s[i]-'0';
            
            now_count = 1;
            if(i==s.length()-1){
                v.push_back({now,now_count});
            }
        }
    }
    if( v.size() <= 2*k ){
        std::cout << n << std::endl;
        return 0;
    }
    ll start=0;
    ll e=0;
    ll sum=v[0].second;

    ll k_count=0;
    ll result = 0;
    if(v[start].first==0){
        k_count++;
    }
    while(e<v.size()-1){
        // std::cout << start <<" "<<e<<" "<<sum << std::endl;
        if(v[e+1].first == 1){
            e++;
            sum+=v[e].second;
            // std::cout << v[e].second << std::endl;
        }else{
            e++;
            sum+=v[e].second;
            if(k_count<k){
                k_count++;
            }else{
                if(v[start].first == 1){
                    sum -= v[start].second;
                    start++;
                    sum -= v[start].second;
                    start++;
                }else{
                    sum -= v[start].second;
                    start++;
                }
            }
        }
        result = max(result,sum);
    }
    std::cout << result << std::endl;
}
// 0 4
// 1 3
// 0 2
// 1 9

// 0001010111101001001001001110100101010101101110

// dp[]

// 0000011111100011000111111

// 累積和
// sum[r]-sum[l] 0の区間を累積和に対応させる。連続したK個の0区間を選ぶことになる。
// 0の区間がX個あるとしたら、X-k個を比較する

// 　---1 ----1 ----1 ---1 ----
//   1-- 1---- 1--- 1--- 1




Measured memory_bytes: 2548
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    string s, t;
    cin >> s >> t;
    int mi = 10000, tmp = 0;
    for (int i = 0; i < s.length() - t.length()+1; ++i) {
        tmp = 0;
        for (int j = 0; j < t.length(); ++j) {
            if (s[i + j] != t[j]) {
                ++tmp;
            }
            //cout << s[i + j];
        }
        //cout << endl;
        mi = min(mi, tmp);

    }
    cout << mi;
}

/*
*/


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define pop(v) (v).back(); (v).pop_back()
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

    string in;
    cin>>in;
    in[3] = '8';
    co(in);
}

Measured memory_bytes: 256
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val (A) = readInts()
    val (B) = readInts()
    val (C) = readInts()
    val (X) = readInts()

    var ans = 0
    for (a in 0..A) for (b in 0..B) for (c in 0..C) {
        if (500 * a + 100 * b + 50 * c == X) ans++
    }

    println(ans)
}

Measured memory_bytes: 37868
import numpy as np
MOD = 1000000007
n = int(input())

cnt = np.ones(n+1)

for i in range(2, n+1):
    m = i
    for j in range(2, i+1):
        while m % j == 0:
            m = m / j
            cnt[j] += 1
ans = 1
for i in range(2, n+1):
    ans = (ans * cnt[i]) % MOD
print(int(ans))

Measured memory_bytes: 12484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	rep(i, N) {
		cin >> v.at(i);
	}

	int a=0, b=0, c=0, x, y, z;
	sort(all(v));
	z = v.at(N-1);
	bitset<1000002> S;
	rep(i, N) {
		if (i != 0) {
			if (v.at(i) == v.at(i-1)) {
				if (!S.test(v.at(i))) {
					x = v.at(i);
					for (int j = x; j <= z; j+=x) {
						S.set(j, 1);
					}
				}
				continue;
			}
		}
		if (i != N-1) {
			if (v.at(i) == v.at(i+1)) {
				if (!S.test(v.at(i))) {
					x = v.at(i);
					for (int j = x; j <= z; j+=x) {
						S.set(j, 1);
					}
				}
				continue;
			}
		}
		if (S.test(v.at(i))) {
			continue;
		} else {
			x = v.at(i);
			a++;
			for (int j = x; j <= z; j+=x) {
				S.set(j, 1);
			}
		}
	}

	std::cout << a << '\n';
}


Measured memory_bytes: 4056
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
  
   int a[5];
 
   int sum = 0;
   int min = 10;
   for(int i = 0;i<5;i++){
     
     cin >> a[i];
     
      int b = 0;
    if(a[i]%10!=0){
     b = 10-a[i]%10;
     
     }
     
     sum = sum+a[i]+b;
   
     
     if(a[i]%10<min&&a[i]%10!=0){
       
       min=a[i]%10;
       
     }
     
     
   }
  
   min = 10-min;
   
   cout << sum-min << endl;
   
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
ll ans=0;
int main(){
	cin>>a>>b;
	for (ll i=40;i>=0;i--){
		ll l=(1ll<<i);
		ll d1=(l<<1);
		ll ans1=a/d1*l+max(0ll,a%d1-l);
		ll ans2=(b+1)/d1*l+max(0ll,(b+1)%d1-l);
		if ((ans2-ans1)%2) ans+=l;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
ct=n*(n-1)//2
ans=[ct]
UF=UF(n)
for i in range(m-1,0,-1):
  if UF.samegroup(l[i][0]-1,l[i][1]-1)==0:
    ct-=UF.size(l[i][0]-1)*UF.size(l[i][1]-1)
  ans.append(ct)
  UF.unite(l[i][0]-1,l[i][1]-1)
for i in range(m-1,-1,-1):
  print(ans[i])

Measured memory_bytes: 35548
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int H, W, A, B, C, **ans, flag=0, i, j, ans_0=0, ans_W=0, len;
	char S[99], T[10], U[10];


	scanf("%s", S);

	len = strlen(S);

	for (i = 0; i <= (len-3) / 2; i++){
		if (S[i] != S[len - i - 1]){
			printf("No\n");
			return 0;
		}

	}
	len = (len - 1) / 2;
	for (i = 0; i <= (len-3) / 2; i++){
		if (S[i] != S[len - i - 1]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

	return 0;

}
    


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	int n; ll x; cin >> n >> x;
	vector<ll> v;
	rep(i, 0, n) {
		ll y; cin >> y;
		v.push_back(abs(y - x));
	}
	ll g = v[0];
	rep(i, 1, v.size()) g = __gcd(g, v[i]);
	cout << g << endl;
}


Measured memory_bytes: 1400
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    v = []
    for i in range(N):
        v.append(sum_of_arithmetic_progression(1, 1, P[i]) / P[i])

    ans = 0.0
    tmp = 0.0
    for i in range(N):
        if i < K:
           tmp += v[i]
        else:
            tmp += v[i]
            tmp -= v[i - K]
        ans = max(ans, tmp)

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 32576
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;

int main(){
	ll ans=0;
	ll w=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='W')
			w++;
	}
	for(int i=0;i<s.size();i++){
		if(s[i]=='W')
			w--;
		if(s[i]=='B')
			ans+=w;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
/*input
sippuu
*/
#include "bits/stdc++.h"
#define pb push_back
#define ll long long
using namespace std;
#define N 400005
#define int long long
ll dard[21][21];
ll A[N], pre[21][N], dp[ (1<<20) + 5 ];

signed main()
{
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5])
		cout<< "Yes";
	else cout<<"No";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll max_sum = 0;
	if(a >= k){
			cout<<k;
			return 0;
		}

	max_sum = a;
	k = k-a;
	if(b >= k){
		cout<<max_sum;
		return 0;
	}
	k = k - b;
	cout<<max_sum - k;


}

Measured memory_bytes: 3636
N = int(input())
red = [3*N] * (2*N)
blue = [-1] * (2*N)
for i in range(N):
    a, b = (int(j) for j in input().split())
    red[a] = b
for i in range(N):
    a, b = (int(j) for j in input().split())
    blue[a] = b
ans = 0
for i in range(1, 2*N):
    for j in range(blue[i]-1, -1, -1):
        if j in red and red.index(j) < i:
            ans += 1
            blue[i] = 0
            red[red.index(j)] = 3 * N
            break
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int i,a,p,pt,d1,d2,d;
	while(1){
		d = 0;
		scanf("%d",&a);
		if (a == 0) break;
		for(i=0;i<a;i++){
			scanf("%d%d%d",&p,&d1,&d2);
			if (d < d1 + d2){
				d = d1 + d2;
				pt = p;
			}
		}
		printf("%d %d\n",pt,d);
	}
	return 0;
}

Measured memory_bytes: 412
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  string s;
  cin >> s;
  int K;
  cin >> K;
  vector<string> v;
  rep(i, 0, s.size()) {
    rep(j, 1, K + 1) {
      if (i + j - 1 < s.size())
        v.push_back(s.substr(i, j));
    }
  }
  sort(all(v));
  v.erase(unique(all(v)),v.end());

  cout << v[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<int> G[5];

int main(void){
    for(int i=0;i<3;i++) {
        int a,b;
        scanf("%d%d", &a, &b);
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bool ans=true;
    for(int i=0;i<4;i++){
        if(G[i].size()>=3)ans=false;
    }
    printf("%s\n",ans?"YES":"NO");
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
sm = sum(a)
for i in range(M):
  if a[i] < sm / 4 / M:
    print("No")
    break
else: print("Yes")

Measured memory_bytes: 61264
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, k ; 
    cin >> n >> k ; 
    vi  a(n+2) ; 
    for (int i=1;i<=n;i++) cin >> a[i] ; 
    for (int i=1;i<=k;i++){
        bool ok=true;
        vi pref(n+2); 
        for (int i=1;i<=n;i++){ 
            int l = max(0LL, i-a[i]) ; 
            int r = min(n+1, i+a[i]+1) ; 
            pref[l]++; pref[r]--;
        } 
        for (int i=1;i<=n;i++) pref[i] += pref[i-1] ; 
        for (int i=1;i<=n;i++) if (pref[i]<n) ok=false; 
        a = pref;
        if (ok) break ; 
    }
    for (int i=1;i<=n;i++) cout << a[i] << " "; 
    cout << endl ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define ll long long int
#define li long int
using namespace std;
int n,weight;
vector<vector<ll>> dp(105,vector<ll> (100005,-1));
vector<int> w(105);
vector<li> v(105);
ll knapsack(int ind,int wt)
{
    if(ind>n||(wt<=0))
        return 0;
    if(dp[ind][wt]==-1)
    {
        if(w[ind]<=wt)
        {
            ll left= knapsack(ind+1,wt-w[ind])+v[ind];
            ll right=knapsack(ind+1,wt);
            dp[ind][wt]=max(left,right);
        }
        else
        {
            dp[ind][wt]=knapsack(ind+1,wt);
        }
    }
    return dp[ind][wt];
}
int main()
{
    cin>>n>>weight;
    fo(i,1,n+1)
        cin>>w[i]>>v[i];
    ll ans=knapsack(1,weight);
    cout<<ans;

}


Measured memory_bytes: 86228
a =int(input())
s = input()
r = 0
m = 0
for i in range(1,a):
    tmp = s[0:i]
    temp = s[i:a]
    tm = set(tmp)
    tp = set(temp)
    for i in tm:
        for j in tp:
            if i == j:
                r +=1
    if m < r:
        m = r
    r = 0
    
print(m)

    

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

//Reindeer with no sense of direction
public class Main{

	int w, h, N, GS, R = 8;
	int[][] map;
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	List<Integer>[][] adj;
	Map<Integer, Integer>[] dp;
	
	int get(int v, int S, int rest){
		if(rest==1&&S==(1<<N))return 1;
		if(R<=rest&&dp[v].containsKey(S))return dp[v].get(S);
		int res = 0;
		for(int k=0;k<4;k++)for(int nv:adj[v][k]){
			if(((S>>nv)&1)==0)continue;
			if(nv==N&&3<=rest)continue;
			res+=get(nv, S-(1<<v), rest-1);
			break;
		}
		if(R<=rest)dp[v].put(S, res);
		return res;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			w = sc.nextInt(); h = sc.nextInt();
			if((w|h)==0)break;
			N = 0;
			map = new int[h][w];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				map[i][j] = sc.nextInt();
				if(map[i][j]==1)N++;
				else if(map[i][j]==0)map[i][j]=-1;
			}
			int id = 0;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(map[i][j]==-1)continue;
				if(map[i][j]==1){
					map[i][j]=id++;
				}
				else {
					map[i][j] = N;
				}
			}
			adj = new List[N+1][4];
			for(int i=0;i<=N;i++)for(int j=0;j<4;j++)adj[i][j]=new ArrayList<Integer>();
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(map[i][j]!=-1){
				for(int k=0;k<4;k++){
					int pi = i+d[k][0], pj = j+d[k][1];
					while(0<=pi&&pi<h&&0<=pj&&pj<w){
						if(map[pi][pj]!=-1)adj[map[i][j]][k].add(map[pi][pj]);
						pi+=d[k][0]; pj+=d[k][1];
					}
				}
			}
			GS = (1<<(N+1))-1;
			dp = new Map[N+1];
			for(int i=0;i<=N;i++)dp[i]=new HashMap<Integer, Integer>();
			dp[N].put(1<<N, 1);
			int res = 0;
			for(int k=0;k<4;k++)if(!adj[N][k].isEmpty())res+=get(adj[N][k].get(0), GS, N+1);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 59000
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
  int64_t v;
  Mint() { v = 0; }
  Mint(int64_t x) { v = x % MOD; if(v < 0) v += MOD; }

  Mint operator-() { return Mint(-v); };
  Mint operator+(Mint x) { return Mint(v + x.v); };
  Mint operator-(Mint x) { return Mint(v - x.v); };
  Mint operator*(Mint x) { return Mint(v * x.v); };
  Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

  Mint& operator+=(Mint x) { return *this = (*this + x); };
  Mint& operator-=(Mint x) { return *this = (*this - x); };
  Mint& operator*=(Mint x) { return *this = (*this * x); };
  Mint& operator/=(Mint x) { return *this = (*this / x); };

  static Mint pow(Mint base, int64_t exp) {
    if(exp == 0) return Mint(1);
    return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
  }

  friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

const int SIZE = 11234567;
mint fact(int n) {
  static vector<mint> factorial = []() {
    vector<mint> _f(SIZE, 1);
    for(int i=1; i<SIZE; i++) _f[i] = _f[i-1] * i;
    return _f;
  }();
  return factorial[n];
}
mint perm(int n, int k) { return n<k ? 0 : fact(n) / fact(n-k); }
mint comb(int n, int k) { return n<k ? 0 : perm(n, k) / fact(k); }

int main() {
  lint N, M;
  cin >> N >> M;

  mint ans = 0;
  for(lint k=1; k<=N; k++) {
    ans += comb(N,k) * pow(-1, k+1) * perm(M-k, N-k);
  }
  ans = perm(M,N) - ans;
  ans *= comb(M,N) * fact(N);

  cout << ans << endl;
}

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

#define N 8


bool col[N],hi[2*N-1],mi[2*N+1];
int row[N];
void point(int y,int x){

  row[y] = x;
  col[x] = false;
  hi[x+y] = false;
  mi[y-x+N-1] = false;

}

void del(int y, int x){

  row[y] = -1;
  col[x] = true;
  hi[x+y] = true;
  mi[y-x+N-1] = true;

}

void print_ans(){
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(row[i] == j) cout << "Q";
      else cout << ".";
    }
    cout << endl;
  }
}

bool is_ok(int y,int x){
  return row[y] == -1 && col[x] == true && hi[x+y] == true && mi[y-x+N-1];
}

void dfs(int r){
  if(r == 8){//??´??????
    print_ans();
    return ;
  }
  if(row[r] != -1){
    dfs(r+1);
  }
  else{
    for(int i=0; i<8; i++){
      if(is_ok(r,i) == true){
	point(r,i);
	dfs(r+1);
	del(r,i);
      }
    }
  }
  return;
}


int main(){

  int k; cin >> k;
  
  memset(row,-1,sizeof(row));
  memset(col,true,sizeof(col));
  memset(hi,true,sizeof(hi));
  memset(mi,true,sizeof(mi));
  
  for(int i=0; i<k; i++){
    int x,y; cin >> y >> x;
    row[y] = x;
    col[x] = false;
    hi[x+y] = false;
    mi[y-x+N-1] = false;
  }
  
  dfs(0);

}

Measured memory_bytes: 1156
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
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/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int c[3][3];
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            cin>>c[i][j];
    int a[3],b[3];
    a[0]=0;
    b[0]=c[0][0]-a[0];
    a[1]=c[1][0]-b[0];
    b[1]=c[1][1]-a[1];
    a[2]=c[2][0]-b[0];
    b[2]=c[2][2]-a[2];
    bool abc=true;
    for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
        if(c[i][j]!=a[i]+b[j])
            abc=false;
    if(abc)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------
/*a1+b1=c11
a1+b2=c12
a2+b1=c21
a2+b2=c22
 a1+b2   a1+b3
 a2+b2   a2+b3
*/



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
#include <cmath>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)


int main(int argc, char *argv[])
{
    int N, M;
    cin >> N >> M;

    // map P -> set(pair<year, index>)
    map<int, set<pair<int, int>>> m;

    // calc order in each P
    Rep(i, M) {
        int p, y;
        cin >> p >> y;
        m[p].insert(make_pair(y, i));
    }

    // map<set<year, index>> to vector<pair<P, index in the P>>
    vector<pair<int, int>> v(M);
    for (auto kv : m) {
        int p = kv.first;
        auto s = kv.second;
        int idx = 1;
        for (auto it=s.cbegin(); it!=s.cend(); ++it) {
            v[it->second] = make_pair(p, idx++);
        }
    }

    // output
    for (auto x : v) {
        printf("%06d%06d\n", x.first, x.second);
    }


    return 0;
}

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

using namespace std;

vector<int> numbers;

void setNum(vector<vector<int> > a){
    numbers.resize(a.size());
    for(int i = 0; i < numbers.size(); i++)numbers[i] = -1;
    int num = 0;
    queue<int> place;
    place.push(0);
    while(place.size()){
        int now = place.front();
        place.pop();
        numbers[now] = num;
        for(int i = 0; i < a[now].size(); i++){
            int next = a[now][i];
            if(numbers[next] == -1){
                place.push(next);
            }
        }
        if(place.size() == 0){
            for(int i = 0; i < numbers.size(); i++){
                if(numbers[i] == -1){
                    place.push(i);
                    num++;
                    break;
                }
            }
        }
    }
}

int main(void){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > a(n);
    for(int i = 0; i < m; i++){
        int s, t;
        cin >> s >> t;
        a[s].push_back(t);
        a[t].push_back(s);
    }
    int q;
    cin >> q;
    setNum(a);
    for(int i = 0; i < q; i++){
        int s, t;
        cin >> s >> t;
        if(numbers[s] == numbers[t])cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


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

using namespace std;

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

    long long res = h * w;
    for (long long i = 1; i <= h - 1; i++) {
        long long a = i * w,
                b1 = (h - i) * (w / 2),
                b2 = ((h - i) / 2) * w,
                c1 = (h - i) * (w - (w / 2)),
                c2 = ((h - i) - ((h - i) / 2)) * w;
        res = min(res, min(
                max(a, max(b1, c1)) - min(a, min(b1, c1)),
                max(a, max(b2, c2)) - min(a, min(b2, c2))));
    }

    for (long long i = 1; i <= w - 1; i++) {
        long long a = h * i,
                b1 = (h / 2) * (w - i),
                b2 = h * ((w - i) / 2),
                c1 = (h - (h / 2)) * (w - i),
                c2 = h * ((w - i) - ((w - i) / 2));
        res = min(res, min(
                max(a, max(b1, c1)) - min(a, min(b1, c1)),
                max(a, max(b2, c2)) - min(a, min(b2, c2))));
    }

    cout << res << endl;
}


Measured memory_bytes: 256
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

n = int(input())

while True:
    if is_prime(n):
        print(n)
        break
    n += 1


Measured memory_bytes: 2940
/**         srijan_de
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/       08.04.2020     **/
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
#include    <bits/stdc++.h>  
using       namespace       std;
using       lli=            long long  int;
using       ulli=           unsigned long long int;
using       ld=             long double;
#define     mem(a,val)      memset( a,  val,  sizeof(a) )
#define     b_s             binary_search
#define     u_b             upper_bound
#define     l_b             lower_bound
#define     nl              cout<<endl
#define     pb              push_back
#define     pf              push_front
#define     ppb             pop_back
#define     ppf             pop_front
#define     in              insert
#define     fi              first
#define     se              second
#define 	pqueue			priority_queue
const lli   MOD=            (int)1e9 + 7;
const lli   MOD1=           (int)1e9 + 9;
const lli   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
lli         tests=          1;
template<class x,class y>x max(x a,y b){return (a>b)?a:b;}
template<class x,class y>x min(x a,y b){return (a<b)?a:b;}
template<class x,class y>x log(x n,y r){return (n>r-1)?1+log(n/r,r):0;}

///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
int32_t main() 
{
	auto start = clock();
	ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);	
	#ifndef ONLINE_JUDGE	
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	#endif
//	cout<<fixed;
//	cout<<scientific;
//	cout<<fixed<<setprecision(12);
	//cin>>tests;
	for(lli test=1;test<=tests;test++) 
	{
//		cout<<"Case #"<<test<<": ";
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
		
		
		string s;
		cin>>s;
		if(s[0]=='7'||s[1]=='7'||s[2]=='7')
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
	}
	cerr<<endl<<endl<<endl<< "Time : " << double(clock() - start) / CLOCKS_PER_SEC <<endl;
	return 0;
}
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.


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

int main() {
  int h,w,k;
  cin>>h>>w>>k;
  string choco[h];
  for(int i=0; i<h; i++) cin>>choco[i];

  int ans = h+w;
  for(int bit=0; bit<(2<<h-1); bit++) {
    int m = __builtin_popcount(bit);
    int cnt = m;
    int count[m+1];
    vector<int> cut;
    for(int i=0; i<m+1; i++) count[i]=0;
    for(int i=0; i<h-1; i++) {
      if((bit>>i)&1) cut.push_back(i+1);
    }
    cut.push_back(h);

    bool loop = true;
    bool out = false;
    for(int i=0; i<w; i++) {
      int posi = 0;
      for(int j=0; j<h; j++) {
        if(j>=cut[posi]) posi++;

        if(choco[j][i]=='1') count[posi]++;
        if(count[posi]>k) {
          cnt++;
          for(int k=0; k<m+1; k++) count[k]=0;
          i--;
          if(loop) out = true;
          loop = true;
          break;
        }
        if(j==h-1) loop=false;
      }

      if(out) break;
    }

    if(!out) ans = min(ans, cnt);
  }


  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;
char a[10] = {0};
int flage;

int main()
{
	flage = 0;
	scanf("%s", &a);
	for(int i = 0;i <= 3;i++)
	{
		if(a[i] == a[i+1]){
		if(a[i] == a[i+2]){
			flage = 3;
			break;
		}
		}
		else if(a[i] == 0 && i>2){
			break;
		}
	}
	if(flage >= 3)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.stream.Collectors;


public class Main {

    public static int gcd(int n,int m){
        return (m==0)?n:gcd(m,n%m);
    }
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int[] num=new int[32];
        //1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,
        // 1\23, 15\24, 2, 2, 5, 4\28, 1\29, 4\30, 1\31, 51\32
        int n=cin.nextInt();
        if(n==1||n==2||n==3||n==5||n==7||n==11||n==13||n==15||n==17||n==19||n==23||n==29||n==31){
            System.out.println("1");
        }
        else if(n==4||n==6||n==9||n==10||n==14||n==21||n==22||n==25||n==26){
            System.out.println("2");
        }
        else if(n==8||n==12||n==18||n==20||n==27){
            System.out.println("5");
        }
        else if(n==28||n==30){
            System.out.println("4");
        }
        else if(n==16){
            System.out.println("14");
        }
        else if(n==24){
            System.out.println("15");
        }
        else if(n==32){
            System.out.println("51");
        }
    }

}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
vector<string> tmp;
int ans,cnt,n;
string s;
string rec(string x){
  while(1){
    //cout << x << endl;
    bool flag=false;
    sort(x.begin(),x.end());
    string a = x;
    if(a.empty()==1) while(a.front()!='0') a.erase(a.begin());
    int mn = atoi(a.c_str());
    reverse(x.begin(),x.end());
    int mx = atoi(x.c_str());
    x = to_string(mx-mn);
    if(x.size()!=n) x = '0'+x;
    //cout << mx << " " <<  mx << " " << x << endl;
    for(int i=0; i<tmp.size(); i++){
      //cout << tmp[i] << " ";
      if(x == tmp[i]){
        ans = i;
        flag = true;
	      break;
      }
    }
    tmp.push_back(x);
    cnt++;
    if(flag == false) return rec(x);
    else return x;
    }
  return 0;
}
int main(){
  while(1){
    cin >> s >> n;
    if(s == "0" && n == 0) break;
    cnt = 0;
    ans = 0;
    while(s.size() != n) s = '0'+s;
    tmp.push_back(s);
    s = rec(s);
    cout << ans << " "<< atoi(s.c_str()) << " " << cnt-ans << endl;
    tmp.clear();
  }
  return 0;
}




Measured memory_bytes: 3204