akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
using namespace std;

#ifndef MDEBUG
#define NDEBUG
#endif

#define x first
#define y second
#define ll long long
#define d double
#define ld long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pss pair<string,string>
#define psi pair<string,int>
#define pis pair<int,string>
#define psl pair<string,ll>
#define pls pair<ll,string>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
// auto fraclt = [](auto&a,auto&b) { return (ll)a.x * b.y < (ll)b.x * a.y; };
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }
template<typename T> void fracn(pair<T,T>&a) {auto g=gcd(a.x,a.y);a.x/=g;a.y/=g;}
template<typename T> struct Index { int operator[](const T&t){auto i=m.find(t);return i!=m.end()?i->y:m[t]=m.size();}int s(){return m.size();} unordered_map<T,int> m; };

ll D[51][2501];

int main(int,char**) {
    ios_base::sync_with_stdio(false);

    ri(N); ri(A);
    vector<int> X(N); rv(X);
    for (int i = 0; i < 51; i++) {
        for (int j = 0; j < 2501; j++) {
            D[i][j] = 0;
        }
    }
  
    D[0][0] = 1;
    int s = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i; j >= 0; --j) {
            for (int k = s; k >= 0; --k) {
                D[j+1][k+X[i]] += D[j][k];
            }
        }
        s += X[i];
    }

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += D[i][i*A];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstring>
using namespace std;
const int mod = 1000000007;

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

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

    int dp[h+1][w];
    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1;
    for(int i = 1; i <= h; i++){
        for(int j = 0; j < 1<<(w-1); j++){
            int raw[w-1];
            for(int k = 0; k < w-1; k++){
                raw[k] = 1&(j>>k);
            }

            bool judge = true;
            for(int k = 1; k < w-1; k++)  if(raw[k] + raw[k-1] == 2)  judge = false;
            if(!judge)  continue;

            for(int k = 0; k < w-1; k++){
                if(k == 0){
                    if(raw[k] == 1){
                        dp[i][k] += dp[i-1][k+1], dp[i][k] %= mod;
                        dp[i][k+1] += dp[i-1][k], dp[i][k+1] %= mod;
                    }else{
                        dp[i][k] += dp[i-1][k], dp[i][k] %= mod;
                    }
                }else{
                    if(raw[k] == 1){
                        dp[i][k] += dp[i-1][k+1], dp[i][k] %= mod;
                        dp[i][k+1] += dp[i-1][k], dp[i][k+1] %= mod;
                    }else{
                        if(raw[k-1] == 0){
                            dp[i][k] += dp[i-1][k], dp[i][k] %= mod;
                        }
                        if(k == w-2){
                            dp[i][k+1] += dp[i-1][k+1], dp[i][k+1] %= mod;
                        }
                    }
                }
            }
        }
    }

    cout << dp[h][x-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}
struct SieveOfEstosthenes {
    int n;
    vector<bool> is_prime;
    vector<int> prime;
    SieveOfEstosthenes(int n) : n(n), is_prime(n, true) {
        is_prime[0] = is_prime[1] = false;
        for (int i = 2; i <= n; ++i) {
            if (is_prime[i]) {
                prime.push_back(i);
                for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
            }
        }
    }
};


void Main() {
	int N; cin >> N;
	vl A(N);
	ll m = 1;
	REP(i,N) {
		cin >> A[i];
		m = max(m, A[i]);
	}
	vi cnt(m + 1, 0);
	SieveOfEstosthenes era(m + 1);
	bool pairwise = true;
	REP(i,N) {
		ll n = A[i];
		// vi in_cnt(m + 1);
		// for (long long j = 2; j * j <= n; ++j) {
		// 	while (n % j == 0) {
		// 		if (in_cnt[j] == 0 && cnt[j] == 1) {
		// 			pairwise = false;
		// 			goto NOT_PAR;
		// 		}
		// 		if (in_cnt[j] == 0) {
		// 			cnt[j]++;
		// 		}
		// 		in_cnt[j]++;
		// 		n /= j;
		// 	}
		// }
		for (long long j = 1; j * j <= n; ++j) {
			if (n % j == 0) {
				if (cnt[j] == 1 && era.is_prime[j]) {
					pairwise = false;
					goto NOT_PAR;
				}
				cnt[j]++;
				if (j != n / j) {
					if (cnt[n / j] == 1 && era.is_prime[n / j]) {
						pairwise = false;
						goto NOT_PAR;
					}
					cnt[n / j]++;
				};
			}
		}
	}
	NOT_PAR:
	if (pairwise) {
		cout << "pairwise coprime" << endl;
		return;
	}
	ll g = A[0];
	FOR(i,1,N) {
		g = gcd(g, A[i]);
	}
	bool setwise = g == 1;
	if (setwise) {
		cout << "setwise coprime" << endl;
		return;
	}
	cout << "not coprime" << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 15580
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file
int main()
{
    IOS;
    int n,m,cnt=0;
    cin>>n>>m;
    int h[n+2];
    int re[n+2];
    //int sad[n+2];
    MEM(re,0);
    //MEM(sad,0);
    rep(i,1,n+1)
    cin>>h[i];
    rep(i,0,m)
    {
        int n1,n2;
        cin>>n1>>n2;
        //sad[n1]++;
        //sad[n2]++;
        if(h[n1]>h[n2])
        {
            if(re[n1]!=-1)
                re[n1]=1;
            re[n2]=-1;
        }
        if(h[n1]<h[n2])
        {
            if(re[n2]!=-1)
                re[n2]=1;
            re[n1]=-1;
        }if(h[n1]==h[n2])
        {
            re[n1]=-1;
            re[n2]=-1;
        }
    }
    rep(i,1,n+1)
    {
        if(re[i]==1||re[i]==0)
            cnt++;
    }
    /*rep(i,1,n+1)
    {
        if(sad[i]==0)
            cnt++;
    }*/
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 4408
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
 
int main(){
    int N, M;
    long X;
    cin >> N >> M >> X;
    vector<long> C(N);
    long ans;
    long A[N][M];
    for (int i=0; i<N; i++){
        cin >> C[i];
        for (int j=0; j<M; j++){
            cin >> A[i][j];
        }
    }
    for (int j=0; j<M; j++){
        int p = 0;
        for (int i=0; i<N; i++){
            p += A[i][j];
        }
        if (p < X){
            cout << -1 << endl;
            return 0;
        }
    }

    for (int bit=0; bit<(1<<N); ++bit){
        vector<long> skill(M, 0);
        long sum = 0;
        for (int i=0; i<N; ++i){
            if (bit & (1<<i)){
                for (int j=0; j<M; j++){
                    skill[j] += A[i][j];
                }
                sum += C[i];
            }
        }
        long a;
        for (int j=0; j<M; j++){
            if (skill[j] < X){
                a = ans;
                break;
            }
            a = sum;
        }
        ans = min(ans, a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
  ll n;
  cin >> n;
  vector<string>s(n);
  vector<ll>t(n);
  for(ll i=0;i<n;i++){
    cin >> s[i] >> t[i];
  }
  ll ans=0;
  string x;
  cin >> x;
  ll ti;
  for(ll i=0;i<n;i++){
    if(s[i]==x){
      ti=i;
      break;
    }
  }
  for(ll i=ti+1;i<n;i++){
    ans+=t[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
[A, B] = [int(i) for i in input().split()]
a = []
b = []
if A%2 == 1:
    s = 0
    t = 1
else:
    s = 1
    t = 0
     
for i in range(int(A*12.5) + t, int((A+1)*12.5) + s):
    a.append(i)
for i in range(10*B, 10*(B+1)):
    b.append(i)

ans = -1
for i in range(len(a)):
    if b[0] <= a[i] and a[i] <= b[-1]:
        ans = a[i]
        break
print(ans)

Measured memory_bytes: 9124
n = int(input())
al = list(map(int, input().split()))
ave = sum(al)/n

ans = 0
ans_diff = abs(ave - al[0])
for i, a in enumerate(al):
    if abs(ave-a) < ans_diff:
        ans = i
        ans_diff = abs(ave-a)
print(ans)


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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

int main(){
    init();

    ll n, k, x, y;  cin >> n >> k >> x >> y;
    cout << min(k, n) * x + max(0ll, n - k) * y;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecint a(n + 1, -1);
  cout << 0 << "\n" << flush;
  string s;
  cin >> s;
  if (s == "Vacant") return 0;
  if (s == "Male") {
    a[0] = a[n] = 1;
  } else {
    a[0] = a[n] = 2;
  }
  int cnt = 0;
  int l = 0;
  int r = n;
  while (cnt <= 19) {
    // cout << "l,r = " << l << " " << r << endl;
    int c = (l + r) / 2;
    cnt++;
	cout << c << "\n" << flush;
    cin >> s;
    if (s == "Vacant") return 0;
    a[c] = (s == "Male") ? 1 : 2;
    // cout << "a[c] = " << a[c] << endl;
    if (((r - c) % 2 == 0 && a[r] != a[c]) ||
        ((r - c) % 2 != 0 && a[r] == a[c])) {
      l = c;
    } else if (((c - l) % 2 == 0 && a[l] != a[c]) ||
               ((c - l) % 2 != 0 && a[l] == a[c])) {
      r = c;
    } else {
      cerr << "error!\n" << flush;
      return 0;
    }
  }
  return 0;

  //////////////////////////////////////////////
}


Measured memory_bytes: 1236
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int H,W;
int diff_row[8] = {-1,-1,-1,0,0,1,1,1},diff_col[8] = {-1,0,1,-1,1,-1,0,1};

int main(){

	scanf("%d %d",&H,&W);

	char** map = new char*[H+2];
	for(int row = 0; row <= H+1; row++){
		map[row] = new char[W+2];
	}

	for(int col = 0; col <= W+1; col++){
		map[0][col] = '.';
		map[H+1][col] = '.';
	}

	for(int row = 0; row <= H+1; row++){
		map[row][0] = '.';
		map[row][W+1] = '.';
	}

	char buf[W+1];

	for(int row = 1; row <= H; row++){
		scanf("%s",buf);
		for(int col = 1; col <= W; col++){
			map[row][col] = buf[col-1];
		}
	}

	vector<Info> broke_points;
	vector<Info> next_broke_points;

	int tmp,count,adj_row,adj_col;

	bool** deleted = new bool*[H+1];
	bool** pushed = new bool*[H+1];

	for(int row = 1; row <= H; row++){
		deleted[row] = new bool[W+1];
		pushed[row] = new bool[W+1];
		for(int col = 1; col <= W; col++){
			deleted[row][col] = false;
			pushed[row][col] = false;
		}
	}

	for(int row = 1; row <= H; row++){
		for(int col = 1; col <= W; col++){
			if(map[row][col] >= '1' && map[row][col] <= '8'){

				tmp = map[row][col] - '0';
				count = 0;

				for(int i = 0; i < 8; i++){
					adj_row = row + diff_row[i];
					adj_col = col + diff_col[i];

					if(map[adj_row][adj_col] == '.')count++;
				}

				if(count >= tmp){
					broke_points.push_back(Info(row,col));
					deleted[row][col] = true;
				}
			}
		}
	}

	if(broke_points.size() == 0){
		printf("0\n");
		return 0;
	}

	int ans = 1;
	int next_adj_row,next_adj_col;


	while(true){

		for(int i = 0; i < broke_points.size(); i++){
			map[broke_points[i].row][broke_points[i].col] = '.';

			for(int k = 0; k < 8;k++){
				adj_row = broke_points[i].row + diff_row[k];
				adj_col = broke_points[i].col + diff_col[k];

				if(deleted[adj_row][adj_col] == false && pushed[adj_row][adj_col] == false && map[adj_row][adj_col] >= '1' && map[adj_row][adj_col] <= '8'){
					tmp = map[adj_row][adj_col] - '0';
					count = 0;

					for(int p = 0; p < 8; p++){
						next_adj_row = adj_row + diff_row[p];
						next_adj_col = adj_col + diff_col[p];

						if(map[next_adj_row][next_adj_col] == '.' || deleted[next_adj_row][next_adj_col] == true){
							count++;
						}
					}

					if(count >= tmp){
						pushed[adj_row][adj_col] = true;
						next_broke_points.push_back(Info(adj_row,adj_col));
					}
				}
			}



		}
		broke_points.clear();

		if(next_broke_points.size() == 0){
			break;
		}
		ans++;

		for(int i = 0; i < next_broke_points.size(); i++){
			deleted[next_broke_points[i].row][next_broke_points[i].col] = true;
			broke_points.push_back(next_broke_points[i]);
		}
		next_broke_points.clear();
	}

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

	return 0;
}

Measured memory_bytes: 6196
n = gets.to_i
ans = Hash.new(0)

(1..n).each do |m|
  pre = m
  count = 0
  if pre % 2 == 0
    until pre % 2 != 0
      pre /= 2
      count += 1
    end
  end
  ans[m] = count
end
puts ans.sort {|(k1, v1), (k2, v2)| v2 <=> v1 }[0][0]


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

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  
  bool ok = false;
  for(int i = 0; i <= n; i++){
    int cnt = k - i * m;
    if(n-i*2 == 0){
      if(cnt == 0){
        ok = true;
      }
      continue;
    }
    if(cnt%(n-i*2) == 0){
      int l = cnt/(n-i*2);
      if(l <= m && l >=0) ok = true;
    }
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
# C
# 2020/04/21  16:18-16:27
l = list(map(str, input()))

n = len(l)
for i in range(2**(n-1)):
    op = ['+']*(n-1)
    for j in range(n):
        if i >> j & 1:
            op[j] = '-'
    if eval(l[0] + op[0] + l[1] + op[1] + l[2] + op[2] + l[3]) == 7:
        print(l[0] + op[0] + l[1] + op[1] + l[2] + op[2] + l[3], '=7', sep='')
        break

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

const int N = 3005;
const long long mod = 1000000007ll, inv2 = mod + 1 >> 1;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

int n, q, a[N];
long long f[N][N], ans = 0ll;

int main () {
	read(n), read(q);
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			f[i][j] = a[i] > a[j] ? 1ll : 0ll;
		}
	}

	for (int i = 1; i <= q; i++) {
		int x, y;
		read(x), read(y);
		f[x][y] = f[y][x] = (f[x][y] + f[y][x]) % mod * inv2 % mod;
		for (int j = 1; j <= n; j++) {
			if (j != x && j != y) {
				f[j][x] = f[j][y] = (f[j][x] + f[j][y]) % mod * inv2 % mod;
				f[x][j] = f[y][j] = (f[x][j] + f[y][j]) % mod * inv2 % mod;
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) ans = (ans + f[i][j]) % mod;
	}
	for (int i = 1; i <= q; i++) ans = ans * 2ll % mod;
	write(ans), putchar('\n');
	return 0;
}

Measured memory_bytes: 70784
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

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

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

N, T = l_inpl()
A = l_inpl()

h = []
min_val = A[0]
for i in range(1, N):
    h.append([A[i], min_val])
    min_val = min(min_val, A[i])

l = [max_val - min_val for max_val, min_val in h]
m = max(l)
print(l.count(m))


Measured memory_bytes: 22396
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=200005;
#define M 1000000007
#define double long double
#define BINF 10000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 5000004
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
 

 


    int n, k;
    cin >> k >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int ans = BINF;
    for(int i = 1; i < n; i++){
        ans = min(ans, k - abs(a[i] - (a[(i - 1 + n) % n])));
    }
    ans = min(ans, k - abs((k - a[n - 1]) + a[0]));

    cout << ans << endl;

    
    





return 0;  
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();

            String ans = "";

            if (a < b) {
                for (int i = 0; i < b; i++) {
                    ans += a;
                }
            } else {
                for (int i = 0; i < a; i++) {
                    ans += b;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 20948
#include<stdio.h>
int main()
{
int a,b,c,d,e,f,g;
scanf("%d %d %d",&a,&b,&c);
d=a+b;
e=a+c;
f=b+c;
if(d<=e && d<=f)
printf("%d\n", d);
else if(e<=d && e<=f)
printf("%d\n", e);
else if(f<=d && f<=e)
printf("%d\n", f);
return 0;
}

Measured memory_bytes: 128
fn main() {
    proconio::input! {
        n: usize,
        l: [u64; n],
    }

    let mut r = 0;
    if n >= 3 {
        for i in 0..n {
            for j in (i + 1)..n {
                for k in (j + 1)..n {
                    if l[i] != l[j]
                     && l[j] != l[k]
                     && l[k] != l[i]
                     && l[i] + l[j] > l[k] 
                     && l[j] + l[k] > l[i]
                     && l[k] + l[i] > l[j] {
                        r += 1;
                    }
                }
            }
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 2128
import sys
# from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 998244353

def solve():
    n = getN()
    # n = 26* 26 * 26
    n -= 1
    ref = [chr(ord("a") + i) for i in range(26)]
    ans = []
    while(n >= 0):
        idx = (n) % 26
        ans.append(ref[idx])
        n = (n // 26) - 1

    ans.reverse()
    print("".join(ans))
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 62064
N,M = map(int,input().split())
a = set(int(input()) for x in range(M))
A = [0]*(N+1)
mod = 1000000007
A[0] = 1
A[1] = 1
for i in a:
  A[i] = -1
if A[1] == -1:
  A[1] = 0
if not(1 in a):
  A[1] = 1
for i in range(2,N+1):
    if A[i] == -1:
      A[i] = 0
    else:
      A[i] = (A[i-2] + A[i-1]) % mod
print(A[N])


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

class Main {
    static int compare = 0;

    static void merge(int[] A, int left, int mid, int right){
        int l1 = mid-left;
        int l2 = right-mid;

        int[] L = new int[l1+1];
        int[] R = new int[l2+1];

        for(int i = 0; i < l1; i++)
            L[i] = A[left + i];

        for(int i = 0; i < l2; i++)
            R[i] = A[mid + i];

        L[l1] = R[l2] = 1000000001; // Sの要素より確実に大きいInfのようなものを番兵として扱う

        int i = 0;
        int j = 0;

        for(int k = left; k < right; k++){
            compare++;

            if(L[i] <= R[j]){
                A[k] = L[i];
                i++;
            }else{
                A[k] = R[j];
                j++;
            }

        }
    }

    static void mergeSort(int[] A, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            mergeSort(A, left, mid);
            mergeSort(A, mid, right);
            merge(A, left, mid, right);
        }
    }

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

        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(input[i]);
        }

        mergeSort(arr, 0, n);

        StringBuilder sb = new StringBuilder();

        sb.append(arr[0]);

        for(int i = 1; i < n; i++){
            sb.append(" " + arr[i]);
        }

        System.out.println(sb.toString());
        System.out.println(compare);
    }
}


Measured memory_bytes: 159968
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
  char S[101];
  long long int K;
  int charP;
  int numP;
  int ans;
  
  // 整数の入力
  scanf("%s", S);
  scanf("%lld", &K);
  
  charP = 0;
  while((numP = S[charP] - '0') == 1){
    if((long long int)(charP + 1) >= K){
      ans = 1;
      break;
    }
    charP++;
  }
  ans = numP;

  // 出力
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
bool used[26];

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  fill(used, used + 26, false);
  for(char c: s){
    if(used[c - 'a']){
      cout << "no" << endl;
      return 0;
    }
    used[c - 'a'] = true;
  }
  cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 256
from bisect import *
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
ans = 0
for i in range(N):
    a = A[N-i-1]
    if C[a] == 0:
        continue
    b = pow(2, a.bit_length())
    if C[b-a]-((a<<1) == b) > 0:
        C[a] -= 1
        C[b-a] -= 1
        ans += 1
print(ans)
    


Measured memory_bytes: 33296
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        long max = Math.max(a, b);
        long min = Math.min(a, b);
        int i = 1;
        long result = 0;
        while (true) {
            if ((max * i) % min == 0) {
                result = max * i;
                break;
            }
            i++;
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int test = Integer.parseInt(scan.next());
        int ok = Integer.parseInt(scan.next());
        //int c = Integer.parseInt(scan.next());
//        int cnt = 0;
//        while(h>0) {
//            h = h-a;
//            cnt++;
//        }
        if(test == ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
N , M = input().split()
array = input().split()
flag = 0

N = int(N)
M = int(M)

iarray = []

for i in array:
    iarray.append(int(i))

total = sum(iarray)

for i in iarray:
    if i >= total/(4*M):
        flag += 1
if flag >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

void solve() {

    vl rec;
    int n;
    SI(n);
    ll sum = 0;
    REP(i, n) {
        ll x;
        SL(x);
        rec.push_back(x);
        sum += x;
    }

    int k = 0;
    ll tmp = 0;
    REP(i, n) {
        k = i;
        tmp += rec[i];
        if(tmp > sum / 2) {
            break;
        }
    }
    ll s1 = 0, s2 = 0;
    for(int i = 0 ; i < k ; i++) {
        s1 += rec[i];
    }
    for(int i = k+1 ; i < n ; i++) {
        s2 += rec[i];
    }
    ll ans = rec[k] - abs(s1 - s2);
    printf("%lld\n", ans);
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}


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

int main() {
    int64_t S, W;
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    
    return 0;
}

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

int main() {
    int N, M;
    std::cin >> N >> M;
    std::vector<std::vector<int> > xs(M);
    for (int i = 0; i < N; ++i) {
        int x;
        std::cin >> x;
        xs[x % M].push_back(x);
    }
    std::vector<int> ntaken(M);
    int ret = 0;
    for (int i = 1; i < (M+1)/2; ++i) {
        int take = std::min(int(xs[i].size()),
                            int(xs[M-i].size()));
        ntaken[i] += take;
        ntaken[M-i] += take;
        ret += take;
    }

    if ((M % 2) == 0) {
        int npair = int(xs[M/2].size()) / 2;
        ntaken[M/2] += 2*npair;
        ret += npair;
    }
    int np = int(xs[0].size()) / 2;
    ntaken[0] += 2*np;
    ret += np;
    for (int i = 0; i < M; ++i) {
        int npairs = 0;
        std::sort(xs[i].begin(), xs[i].end());
        for (int y = 1; y < xs[i].size(); ++y) {
            if (xs[i][y] == xs[i][y-1]) {
                ++npairs;
                ++y;
            }
        }
        npairs = std::min(npairs, (int(xs[i].size()) - ntaken[i]) / 2);
        ret += npairs;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second

const int mo=1e9+7;

int n,m,dp[305][305][305],lim[305][2];
bool vis[305][305][305];

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i,j,k,l,r,x;
	scanf("%d%d",&n,&m);
	memset(vis,1,sizeof(vis));
	for (i=1;i<=m;i++)
	{
		scanf("%d%d%d",&l,&r,&x);
		if (x==1)
		{
			for (j=0;j<=n;j++)
			for (k=0;k<=n;k++)
				vis[r][j][k]&=j<l;
		}
		if (x==2)
		{
			for (j=0;j<=n;j++)
			for (k=0;k<=n;k++)
				vis[r][j][k]&=j>=l&&k<l;
		}
		if (x==3)
		{
			for (j=0;j<=n;j++)
			for (k=0;k<=n;k++)
				vis[r][j][k]&=k>=l;
		}
	}
	dp[0][0][0]=1;
	for (i=0;i<n;i++)
	for (j=0;j<=i;j++)
	for (k=0;k<=j;k++)
	{
		if (dp[i][j][k]&&vis[i][j][k])
		{
			(dp[i+1][j][k]+=dp[i][j][k])%=mo;
			(dp[i+1][i][j]+=dp[i][j][k])%=mo;
			(dp[i+1][i][k]+=dp[i][j][k])%=mo;
		}
	}
	int Ans=0;
	for (j=0;j<=n;j++)
	for (k=0;k<=j;k++)
		if (vis[n][j][k]) (Ans+=dp[n][j][k])%=mo;
	printf("%d\n",Ans);
}


Measured memory_bytes: 135424
def souwa(x):
    total = 0
    while x > 0:
        total += int(x%10)
        x = int(x/10)
    return total

n,a,b = map(int,input().split())
result = 0
for i in range(1,n+1):
    if a <= souwa(i) and souwa(i) <= b:
        result += i
print(result)

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

int main()
{
  int N;
  cin >> N;
  vector<int> p(N);
  for (auto & _p : p)
    cin >> _p;
  int cnt = 0;
  for (int i = 0; i < N; ++i)
  {
    if (p[i] - 1 == i)
    {
      ++cnt;
      ++i;
    }
  }
  cout << cnt;
  return 0;
}


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

int n, h[100000], dp[100000];

int main(){
	scanf("%d", &n);
	for (int i=0; i<n; i++) scanf("%d", &h[i]);
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for (int i=2; i<n; i++) dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
	printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a<b&&b<c) System.out.println("Yes");
		else System.out.println("No");

	}

}

Measured memory_bytes: 26208
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n;deque<int> a;
signed main(){
  cin>>n;
  rep(i,3*n){
    int aa;cin>>aa;a.push_back(aa);
  }
  sort(a.begin(),a.end(), greater<int>());int ans = 0, cnt = 0;
  rep(i,3*n){
    if(cnt == n)break;
    if(i % 2 == 1){
      cnt++;ans += a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2688
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    int la = 1, ra = n;
    for(int i = 0; i < m; ++i)
    {
        int l,r;
        cin >> l >> r;
        la = max(l,la);
        ra = min(r,ra);
        if(ra - la < 0) break;
    }
    if(ra - la < 0)
    {
        cout << "0\n" << endl;
        return 0;
    }
    cout << 1 + ra - la << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int N,M;

priority_queue<pair<int, int>> que;
int main(){
  cin >> N >> M;
  int A[N];
  int B[M];
  int C[M];

  vector<int> cands;
  for(int i=0; i<N; i++){
    cin >> A[i];
    que.push(make_pair(A[i], 1));
  }

  for(int i=0; i<M; i++){
    cin >> B[i] >> C[i];
    que.push(make_pair(C[i], B[i]));
  }

  long long ans = 0;
  rep(i,N){
    pair<int, int> target = que.top();
    que.pop();
    if(target.second > 1){
      que.push(make_pair(target.first, target.second - 1));
    }
    ans += target.first;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int popcount(T n) { return n ? 1 + popcount(n & (n - 1)) : 0; }
#endif
#ifdef __GNUC__
template <class T> int popcount(T n);
template <> int popcount(unsigned int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(unsigned long long n) { return n ? __builtin_popcountll(n) : 0; }
template <> int popcount(long long n) { return n ? __builtin_popcountll(n) : 0; }
#endif

#define rep (i, n) for (int i = 0; i < (int)n; ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))


template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

template <class T> void print(T a, int n, int br = 1, const string& deli = ", ") { cout << "{ "; for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } cout << " }"; while (br--) cout << endl; }
template <class T> void print(const vector<T>& v, int br = 1, const string& deli = ", ") { print(v, v.size(), br, deli); }


int main()
{
    ll a, b;
    cin >> a >> b;
    ll low = a - b, upper = a + b;

    static bool is_prime[1000100];
    static vector<int> factors[1000100];
    for (ll i = 2; i * i <= upper; ++i)
        is_prime[i] = true;

    for (ll i = 2; i * i <= upper; ++i)
    {
        if (is_prime[i])
        {
            for (ll j = 2 * i; j * j <= upper; j += i)
                is_prime[j] = false;
            for (ll j = (low + i - 1) / i * i; j <= upper; j += i)
                factors[j - low].push_back(i);
        }
    }

    int res = 0;
    for (ll i = max(2LL, low); i <= upper; ++i)
    {
        bool is_fox = true;
        int prev_e = 100000;
        ll num = i;
        vector<int>& f = factors[i - low];
        for (ll j = 0; j < f.size(); ++j)
        {
            int e = 0;
            while (num % f[j] == 0)
                num /= f[j], ++e;
            if (e > prev_e)
            {
                is_fox = false;
                break;
            }
            prev_e = e;
        }
        if (is_fox)
            ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 37000
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

Measured memory_bytes: 3964
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define MAX_C 1000000001
#define MOD 1000000007


int main() {
  ll n, k;
  cin >> n >> k;
  
  ll ans = 0;

  for (ll p = k; p <= n+1; p++) {
    ll mn = 0, mx = 0;
    /*for (int i = 0; i < p; i++) {
      mn += i;
      mx += (n - i);
    }*/
    mn = (p-1) * p / 2;
    mx = p * n - mn;
    ans = (ans + mx - mn + 1) % MOD;
  }

  cout << ans << endl;
}


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

#define rep(i, s, n) for(int (i) = (s); (i) < (n); ++(i))
#define print(x) cout << (x) << endl 
#define min2(a, b) ((a) < (b)) ? (a) : (b)
#define max2(a, b) ((a) > (b)) ? (a) : (b)

using namespace std;

int A[4];
string S = "";

void dfs(int index, int sum, string str){
    if(S != ""){
        return;
    }
    if(index > 3){
        if(sum == 7) S = str + "=7";
        return;
    }
    dfs(index + 1, sum + A[index], str + "+" + to_string(A[index]));
    dfs(index + 1, sum - A[index], str + "-" + to_string(A[index]));
}

int main(){
    string s;
    cin >> s;
    rep(i, 0, 4) A[i] = s[i] - '0';
    dfs(1, A[0], to_string(A[0]));
    print(S);
    return 0;
}

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

#define rep(i, n) for(int i=0; i<n; i++)

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
  int n,k;
  int a[200000];
  scanf("%d %d", &n, &k);
  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
    if(i>=k){
      if(a[i]>a[i-k]){
        printf("Yes\n");
      }else{
        printf("No\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2440
S = input()
N = len(S)
n = int((N-1)/2)
S_r = S[::-1]

S1 = S[0:n]
N1 = len(S1)
n1 = int((N1-1)/2)
if n1 < 1:
  n1 = 1
S1_r = S1[::-1]

S2 = S[int((N+3)/2)-1:N]
N2 = len(S2)
n2 = int((N2-1)/2)
if n2 < 1:
  n2 = 1
S2_r = S2[::-1]

if S[0:n]==S_r[0:n] and S1[0:n1]==S1_r[0:n1] and S2[0:n2]==S2_r[0:n2]:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let (x1, y1, x2, y2): (i32, i32, i32, i32) = (read(), read(), read(), read());
    // 何らかで(0, 0)を頂点にすると、もう一つとして(x, y)があったら(x -y, x + y), (-y, x)
    let (x, y) = (x2 - x1, y2 - y1);
    println!("{} {} {} {}", x - y + x1, x + y + y1, -y + x1, x + y1);
}


Measured memory_bytes: 2080
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node
{
    int key;
    Node *right, *left, *parent;
};
Node *root, *NIL;
void insert(int k)
{
    Node *y=NIL;
    Node *x=root;
    Node *z;
    z=(Node*)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
    while(x!=NIL)
    {
        y=x;
        if(z->key<x->key)
        {
            x=x->left;
        }else
        {
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL)
    {
        root=z;
    }
    else
    {
        if(z->key<y->key)
        {
            y->left=z;
        }
        else
        {
            y->right=z;
        }
    }
}
void inorder(Node *u)
{
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u)
{
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main()
{
    int n,i,x;
    string com;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        cin>>com;
        if(com=="insert")
        {
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}

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

int main(void){
    int n, q;
    cin >> n >> q;
    dsu tree(n);
    for(int i = 0; i < q; i++){
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0){
            tree.merge(u, v);
        }
        else{
            if(tree.same(u, v)){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
    }
    return 0;
}

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

int main(){
  int n, m, x; cin >> n >> m >> x;
  
  int ans = 0;
  int gat; cin >> gat;
  
  while(gat < x){
    ans++;
    cin >> gat;
  }
  
  cout << min(ans, m - ans) << endl;
}

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

int ahah(int i){
    int k=1;
    for(int j=0;j<i;j++) k*=10;
    return k;
}

int eiei(int A,int keta){
    vector<int> a(keta);
    vector<int> b(keta);
    int k=0;
    while(A!=0){
        a[k]=A%10;
        b[k]=A%10;
        A/=10;
        k++;
    }
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    
    int res=0;
    
    for(int i=0;i<keta;i++){
        res+=(a[i]-b[i])*ahah(i);
    }
    
    return res;
}

int main(){
    int A,keta;
    while(1){
        cin>>A>>keta;
        if(A==0 && keta==0) break;
        vector<int> vec;
        int aj,aij,aa;
        bool flag=false;
        bool judge=true;
        int tmp=A;
        vec.push_back(tmp);
        
        while(judge){
            tmp=eiei(tmp,keta);
            vec.push_back(tmp);
            for(int i=0;i<vec.size();i++){
                for(int j=i+1;j<vec.size();j++){
                    if(vec[i]==vec[j]){
                        aj=i;
                        aij=j-i;
                        aa=vec[i];
                        flag=true;
                        break;
                    }
                }
                if(flag){
                    judge=false;
                    break;
                }
            }
        }
        cout<<aj<<" "<<aa<<" "<<aij<<endl;
        
        
    }
    
    return 0;
}



Measured memory_bytes: 3072