akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint fact[100005];

modint nPr(int n, int r) {
  if (n < 0 or r < 0 or n < r) {
    return 0;
  }
  return fact[n] / fact[n - r];
}

int main() {
  fact[0] = fact[1] = 1;
  for (int i = 2; i < 100005; i++) {
    fact[i] = fact[i - 1] * i;
  }
  int N, K;
  cin >> N >> K;
  vector<vector<int>> edges(N, vector<int>());
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  modint ans = K;
  vector<int> visited(N);
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    visited[v] = true;
    int n_edges = 0;
    for (int e : edges[v]) {
      if (visited[e]) continue;
      n_edges++;
      que.push(e);
    }
    if (v == 0) {
      ans *= nPr(K - 1, n_edges);
    } else {
      ans *= nPr(K - 2, n_edges);
    }
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 7672
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <complex>
using namespace std;

int main() {
    string str;
    int n;
    cin >> str >> n;
    for(int i = 0; i < n; i++){
        string com;
        cin >> com;
        if(com == "print"){
            int a, b;
            cin >> a >> b;
            cout << str.substr(a, b - a + 1) << endl;
            continue;
        }
        if(com == "reverse"){
            int a, b;
            cin >> a >> b;
            reverse(str.begin() + a, str.begin() + b +1);
            continue;
        }
        if(com == "replace"){
            int a, b;
            string r;
            cin >> a >> b >> r;
            str.replace(a, b - a + 1, r);
            continue;
        }

    }
}


Measured memory_bytes: 3208
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 55
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
bool check(vector <int> A, int x, int K) {
	vector <int> mods;
	for (int a : A) mods.push_back(a % x);
	sort(ALL(mods));
	int l = 0, r = mods.size() - 1;
	int ops = 0;
	while (true) {
		while (l < r and mods[l] % x == 0) l++;
		while (l < r and mods[r] % x == 0) r--;
		if (l >= r) return mods[l] % x == 0 and ops <= K;
		int l_ops = mods[l];
		int r_ops = (x - mods[r]);
		int val = min(l_ops, r_ops);
		mods[l] -= val;
		mods[r] += val;
		ops += val;
	}
}
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");
	
	int N, K;
	scanf("%d %d", &N, &K);
	vector <int> A(N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	int sum = accumulate(A.begin(), A.end(), 0);
	vector <int> facs;
	for (int v = 1; v * v <= sum; v++) if (sum % v == 0) {
		facs.push_back(v);
		if(v * v != sum) facs.push_back(sum / v);
	}
	sort(ALL(facs));
	reverse(ALL(facs));
	for (int fac : facs) if (check(A, fac, K)) {
		printf("%d\n", fac);
		break;
	}
	return 0;
}

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


void solve(long long H, long long N, std::vector<long long> A, std::vector<long long> B){
    vector<vector<int>> dp(1001, vector<int>(10001));
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= H; j++) {
            int a = (j - A[i] >= 1) ? dp[i][j - A[i]] + B[i] : B[i];
            int b;
            if (i - 1 >= 0) {
                b = dp[i - 1][j];
            } else {
                b = a;
            }
            int result = a > b ? b : a;
            dp[i][j] = result;
            // cout << result << " ";
        }
        // putchar('\n');
    }
    cout << dp[N - 1][H] << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(H, N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 39424
# https://atcoder.jp/contests/abc159/tasks/abc159_b

S = input()
n = len(S)
s1 = S[:(n - 1) // 2]
s2 = S[((n + 3) // 2):-1]

if S == S[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    std::vector<int> a;
    a.pb(1);
    rrep(i,2,100){
        rrep(j,2,100){
            if(pow(i,j)>1000)break;
            else a.pb(int(pow(i,j)));
        }
    }
    int x;
    std::cin >> x;
    sort(all(a));
    std::cout << *(ub(all(a),x)-1) << std::endl;
}

Measured memory_bytes: 384
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*when the going gets tough the tough gets going  */
/*we are what we repeatedly do , Excellence then is not an act but a habit  - aristotle */
/*The best way to predict the future is to create it - abraham lincoln*/
/*First think , second believe , third dream and finally dare - walt disney*/
/*It is during our darkest moments that we must focus to see the light */
/*Nothing is impossible the word itself says "i'm fucking possible man just try me again and again till i seem impossible "*/
/*Dont judge each day by the harvest you reap but by the seeds you plant */
/*Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment*/
/*Success is not final failure is not fatal : it is the courage to continue that counts */ 
/*the future belongs to those who believe in the beauty of their dreams */
/*The pessimist complains about the wind , the optimist waits for it to change; the realist adjusts the sails  */
/*Believe you can and you are half way there */
/*Everything has beauty but not everyone sees it */
/*Life is not about finding yourself , life is about creating yourself*/
/*You are the average of the 5 people you spend the most time with .........*/
/*Everything is hard before it is easy see for example now the list of examples is very long hahahahahaha...... ......*/
/*I believe in miracles .......*/
#include<bits/stdc++.h>
#define LL long long 
#define pb push_back

#define PII pair<int , int > 
#define PLL pair<LL , LL >
#define LD long double
#define VLL vector<LL>
#define VPII vector<PII>
#define VI vector<int>
#define VPLL vector<PLL>
#define VLD vector<LD>
#define VVI vector<VI>
#define VVLL vector<VLL>
#define VVPLL vector<VPLL>
#define VVII vector<VPII>
#define IN insert
#define wht while (t--)
#define FU( i , a  , n ) for ( int i = (int)a ; i <=(int)n ; i++  )
#define FD( i , n , a ) for (int i = (int)n ; i >=(int)a ;i--)
#define REP(i,n) for ( int i = 0 ; i < (int)n;  i++)
#define FST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define SZ(a) int((a).size())
#define pi(n) printf("%d" , n ) 
#define pl(n) printf("%lld" , n )
#define ff first
#define ss second
#define ii(n) scanf("%d" , &n)
#define il(n) scanf("%lld" , &n )
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define ALL(V) V.begin(), V.end()
#define ic(n) cin>>n
#define pr printf
#define INF 99999999
#define en endl
using namespace std ;
string str ;
const int tt = 0;
 void solve()
 {
 	int   m , n ,a , b ,c ;
 	map<string ,  int > mp;
 	cin>> n; 
 	REP(i, n)
 	{
 		cin>> str;
 		mp[str]++;
 	}
 	cout << "AC x "<< mp["AC"]<< en; 
 	 	cout << "WA x "<< mp["WA"]<< en; 
 	 	 	cout << "TLE x "<< mp["TLE"]<< en; 
 	cout << "RE x "<< mp["RE"]<< en;  	
 }
int main()
{
	FST;
	
    if (tt)
    {
    	int t;
    	cin>> t ;
    	while (t--)
    	{
    		solve();
    	}
    }
    else
    {
    	solve();
    }
	return 0 ;
	
 
} 

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

def witness(a, n, t, u):
    x = pow(a, u, n)  # x0 = a^u mod nを計算
    y = x

    for _ in range(0, t):
        y = (x * x) % n

        # 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
        if y == 1 and x != 1 and x != (n - 1):
            return True
        x = y
    return y != 1

def is_probably_prime(n, witnesses):
    t = 1
    u = n >> 1
    while u & 1 == 0:
        t = t + 1
        u >>= 1
    assert(2**t * u == n - 1)

    for a in witnesses:
        if a < n and witness(a, n, t, u):
            return False
    return True

def is_definitely_prime(n):
    if ((not (n & 1)) and n != 2) or (n < 2) or ((n % 3 == 0) and (n != 3)):
        return False
    if n <= 3:
        return True
    return is_probably_prime(n, [2, 7, 61])

n = int(input())
answer = 0
for _ in range(0, n):
    m = int(input())
    if is_definitely_prime(m):
        answer = answer + 1
print(answer)


Measured memory_bytes: 5628
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int X, A;
    cin >> X >> A;
    if (X < A) {
        write(0);
    }
    else {
        write(10);
    }
}

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

#define INF 0x3f3f3f3f
#define int long long
#define pii pair<int, int>

const int N = 3005;

int dp[N][N], a[N];
int n;

int solve(int beg, int end) {     // maximum difference you get for [beg, end]
    if(beg == end)
        return dp[beg][end] = a[beg];
    if(dp[beg][end] != -1)
        return dp[beg][end];
    dp[beg][end] = max(a[beg] - solve(beg+1, end), a[end] - solve(beg, end-1));
    return dp[beg][end];
}

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

    int i;
    memset(dp, -1, sizeof(dp));

    cin >> n;
    for(i = 1 ; i <= n ; i++)
        cin >> a[i];
    cout << solve(1, n) << endl;
    return 0;
}


Measured memory_bytes: 71040
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,Ma,Mb,K=1,C[45];
ll A[45]={},B[45];
ll T,a,b;
ll ans=0;
bool h,o;
//bool D[100005];
char str1[55][55],str2[55][55];
string str;
int main(){
	cin>>str;
	for(int i=0;i<str.size();++i){
		A[str[i]-'a']++;
	}
	for(int i=0;i<27;++i){
		if(A[i]%2>0)h=true;
	}
	if(h)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main() {
 	int occ[110] = {0} ; 
  int x, n; 
  cin >> x >> n; 
  int i; 
  int l; 
  for (i = 0; i < n; i ++) {
    cin >> l; 
    occ[l] ++; 
  }
  int petit; 
  int pointeur = x; 
  if (occ[pointeur] == 0) {cout << x; return 0; }
  pointeur = x-1; 
  while ((pointeur >= 0) && (occ[pointeur] != 0)) 
    pointeur --; 
  if (pointeur < 0)
    petit = -1; 
  else
  petit = pointeur; 
  int grand; 
  pointeur = x+1; 
  while ((pointeur <= 100) && (occ[pointeur] != 0)) 
    pointeur ++;
  if (pointeur > 100)
    grand = 101; 
  else
    grand = pointeur; 
  if (grand-x < x-petit)
    cout << grand; 
  else	
    cout << petit;
  return 0; 
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

var hopes [2][2001][2001]int

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	q := getNextInt(scanner)

	n := int(1e5)
	likes := make([]int, n+1)

	for i := 1; i <= n; i++ {
		likes[i] = isPrime(i)
	}

	for i := n; i > 0; i-- {
		likes[i] &= likes[(i+1)>>1]
	}

	for i := 1; i <= n; i++ {
		likes[i] += likes[i-1]
	}

	for i := 0; i < q; i++ {
		l := getNextInt(scanner)
		r := getNextInt(scanner)
		fmt.Fprintln(writer, likes[r]-likes[l-1])
	}

	writer.Flush()
}

func isPrime(n int) int {
	if n == 1 {
		return 0
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 && n/i != 1 {
			return 0
		}
	}
	return 1
}


Measured memory_bytes: 4736
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
const int N = 100005;
const int mod = 1000000007;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	string a[n+1];
	for (int i = 0; i < n; i++)
	cin >> a[i];
	ll dp[n+1][m+1];
	dp[0][0] = 1;
	for (int i = 1; i < n; i++)
	{
	    dp[i][0] = (a[i][0] == '.' ? dp[i-1][0] : 0 );
	}
	for (int i = 1; i < m; i ++)
	{
	    dp[0][i] = (a[0][i] == '.' ? dp[0][i-1] : 0);
	}
	for (int i = 1; i < n; i ++)
	{
	    for (int j = 1; j < m; j ++)
	    {
	        if ( a[i][j] == '#')
	        {
	            dp[i][j] = 0;
	        }
	        else
	        {
	            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
	        }
	    }
	}
	cout << dp[n-1][m-1] << endl;
	return 0;
}


Measured memory_bytes: 9088
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
if h%3!=0 and w%3!=0:
    ansh=h*w
    for j in range(1,h):
        area1=w*j
        number=w//2
        area2=(h-j)*number
        area3=(h-j)*(w-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<ansh:
            ansh=check
        else:
            continue  
    answ=w*h
    for j in range(1,w):
        area1=h*j
        number=h//2
        area2=(w-j)*number
        area3=(w-j)*(h-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<answ:
            answ=check
        else:
             continue
    print(min(ansh,answ,w,h))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    int x=0;
    rep(i,4){
        char c;
        cin>>c;
        x+=(c=='+')-(c=='-');
    }
    cout<<x<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main {
    def main(args : Array[String]) : Unit = {
        val input = readLine().split(" ").map(_.toInt)
        val w = input(0)
        val h = input(1)
        val x = input(2)
        val y = input(3)
        val r = input(4)
        if ((x - r) >= 0 && (x + r) <= w && (y - r) >= 0 && (y + r) <= h) println("Yes") else println("No")
    }
}

Measured memory_bytes: 43748
#include <stdio.h>
#include <stdlib.h>
int main()
{
	char s[4];
	
	scanf("%s",s);
	
	if(s[0] == '7'||s[1] == '7'||s[2] == '7')
		printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;
	cin >> s;

	for (int i = 0; i < 19; i++)
	{
		if (s[i] == ',')
			printf(" ");
		else
			printf("%c", s[i]);
	}
	printf("\n");
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

// ax+by=gcd(a,b) 返り値はgcd(a,b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}

ll modinv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    ll u = x % m;
    if (u < 0) return u += m;
    return u;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


const int MAX = 200010;
const int MOD = 1e9 + 7;
ll com[MAX];

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

    com[0] = 1;
    for (int i = 0; i < MAX; ++i) {
        com[i+1] = com[i] * (n-i);
        com[i+1] %= MOD;
        com[i+1] *= modinv(i+1, MOD);
        com[i+1] %= MOD;
    }

    ll res = modpow(2, n, 1e9+7) - 1;
    res -= com[a];
    if(res < 0) res += MOD;
    res -= com[b];
    if(res < 0) res += MOD;

    cout << res << endl;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] xy = br.readLine().split(" ");
        int x = Integer.parseInt(xy[0]);
        int y = Integer.parseInt(xy[1]);
        
        
        
        System.out.println(x + y/2);
    }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n,m;
  cin >> n >> m;
  cout << (1900*m+100*(n-m))*pow(2,m) <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	char c[4];

	scanf("%s",c);

	if(c[0]!=c[1])  {printf("Yes"); return(0);}
	if(c[1]!=c[2])  {printf("Yes"); return(0);}
	printf("No"); return(0);
}


Measured memory_bytes: 128
N = gets.to_i
A = gets.split(" ").map(&:to_i)
num1 = 0
A.each do |a|
  num2 = 0
  A.each do |i|
    num3 = (a - i).abs
    num2 = num3 if num3 > num2
  end
  num1 = num2 if num2 > num1
end
puts num1


Measured memory_bytes: 1788
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(pow(n, 0.5)) + 1):
        if n % k == 0:
            return False
    return True


def resolve():
    n = int(input())
    primes = []
    for i in range(1, n + 1):
        if is_prime(i):
            primes.append(i)

    fact = []
    for prime in primes:
        ex = 0
        p = prime
        while n // p:
            ex += n // p
            p *= prime
        fact.append(ex)

    cnt_74 = cnt_24 = cnt_14 = cnt_4 = cnt_2 = 0
    for i in fact:
        if i >= 74:
            cnt_74 += 1
        if i >= 24:
            cnt_24 += 1
        if i >= 14:
            cnt_14 += 1
        if i >= 4:
            cnt_4 += 1
        if i >= 2:
            cnt_2 += 1

    res1 = max(0, cnt_24 * (cnt_2 - 1))
    res2 = (cnt_4 * (cnt_4 - 1)) // 2 * max(0, cnt_2 - 2)
    res3 = max(0, cnt_14 * (cnt_4 - 1))
    print(cnt_74 + res1 + res2 + res3)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  double L;
  cin >> L;
  double v = 1.0;
  rep(i, 3) { v *= (L / 3.0); }
  cout << fixed << setprecision(7) << v << endl;
  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
int x, y, flag;

int main() {
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	std::string s;
	std::cin >> s;
	std::cout << s[0] << s[1] << s[2] << std::endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<int(b);i++)
using ll = long long;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n, 0);
    REP(i, 0, n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    int prev = -1, aa = -1, bb = -1;
    REP(i, 0, n) {
        if (prev != a[i]) {
            prev = a[i];
        } else {
            if (aa == -1) {
                aa = prev;
            } else {
                bb = prev;
                break;
            }
            prev = -1;
        }
    }
    if (aa == -1 || bb == -1) {
        cout << 0 << endl;
    } else {
        cout << ll(aa) * ll(bb) << endl;
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};


int main()
{
    int N;
    cin >> N;
    int T,A;
    cin >> T >> A;
    A *= 1000;
    double x;
    long long tempr;
    long long mini;
    long long minidif = 1 << 20;
    for(int i = 0;i < N;++i)
    {
        cin >> x;
        tempr = T * 1000 - x * 6;
        if(A > tempr)
        {
            if(minidif > A - tempr)
            {
                mini = i + 1;
                minidif = A - tempr;
            }
        }   
        else
        {
            if(minidif > tempr - A)
            {
                mini = i + 1;
                minidif = tempr - A;
            }
        }
    }
    cout << mini << '\n';
}

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

vector <ll> id;

ll find(ll i){
	if (id[i] < 0) return i;
	return id[i] = find(id[i]);
}

ll unio(ll i,ll j){
	ll a = find(i);
	ll b = find(j);
	if (a == b) return 0;
	if (id[b] < id[a]) swap(a,b);
	id[a] += id[b];
	id[b] = a;
	return id[a];
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,m;
    cin >> n >> m;
    id.resize(n+1,-1);
    for (int z=0;z<m;z++){
    	ll a,b,c;
    	cin >> a >> b >> c;
    	unio(a,b);
    }
    ll ans = 0;
    for (int z=1;z<=n;z++){
    	if (id[z] < 0) ans++;
    }
    cout << ans << endl;
    cin >> n;
}

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

int main()
{
	long long n;
	scanf("%lld", &n);
	int min{100};
	for (long long i = 1; i * i <= n; i++)
	{
		if (n % i) continue;
		long long quo{n / i};
		int digit{};
		for (long long ten_pow = 1; ten_pow <= quo; ten_pow *= 10)
			digit++;
		min = std::min(min, digit);
	}
	printf("%d\n", min);

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const long long inf = 1e18+7;
long long x[200005];
struct SegmentT{
    int l,r;
    //f[i], f[i]-i, f[i]+i
    long long d[3];
    long long c;
    SegmentT(){
        for(int i = 0; i < 3; i++) d[i] = inf;
        c = 0;
    }
};
SegmentT t[800005];

long long max(long long a,long long b){ return a>b?a:b; }

long long min(long long a,long long b){ return a>b?b:a; }

SegmentT merge(SegmentT& u,SegmentT& v){
    SegmentT res;
    res.l = u.l, res.r = v.r, res.c = 0;
    for(int i = 0; i < 3; i++) res.d[i] = min(u.d[i],v.d[i]);
    return res;
}

void build(int p,int l,int r){
    t[p].l = l, t[p].r = r, t[p].c = 0;
    if(l==r){
        for(int i = 0; i < 3; i++) t[p].d[i] = inf;
    }
    else{
        int m = (l+r)/2;
        build(2*p,l,m);
        build(2*p+1,m+1,r);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

void spread(int p){
    if(t[p].c!=0){
        long long c = t[p].c; t[p].c = 0;
        for(int i = 0; i < 3; i++){
            t[2*p].d[i] += c;
            t[2*p+1].d[i] += c;
        }
        t[2*p].c += c, t[2*p+1].c += c;
    }
}

void segChange(int p,int l,int r,long long v){
    if(l<=t[p].l && r>=t[p].r){
        for(int i = 0; i < 3; i++) t[p].d[i] += v;
        t[p].c += v;
    }
    else{
        spread(p);
        int m = (t[p].l+t[p].r)/2;
        if(l<=m) segChange(2*p,l,r,v);
        if(r>=m+1) segChange(2*p+1,l,r,v);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

void pointChange(int p,int x,long long v){
    if(t[p].l==t[p].r){
        long long offset = t[p].l;
        if(v<t[p].d[0]){
            t[p].d[0] = v;
            t[p].d[1] = v-offset;
            t[p].d[2] = v+offset;
        }
    }
    else{
        spread(p);
        int m = (t[p].l+t[p].r)/2;
        if(x<=m) pointChange(2*p,x,v);
        else pointChange(2*p+1,x,v);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

SegmentT segAsk(int p,int l,int r){
    if(l<=t[p].l && r>=t[p].r) return t[p];
    else{
        spread(p);
        int m = (t[p].l+t[p].r)/2;
        SegmentT u,v;
        if(l<=m) u = segAsk(2*p,l,r);
        if(r>=m+1) v = segAsk(2*p+1,l,r);
        return merge(u,v);
    }
}

long long abs(long long u){ return u>0?u:-u; }

void printTable(int n){
    for(int i = 1; i <= n; i++){
        SegmentT res = segAsk(1,i,i);
        printf("%lld ",res.d[0]);
    }
    printf("\n");
}

int main(){
    int n,q,a,b;
    scanf("%d%d%d%d",&n,&q,&a,&b);
    for(int i = 1; i <= q; i++) scanf("%lld",&x[i]);
    build(1,1,n);
    pointChange(1,a,abs(x[1]-b));
    pointChange(1,b,abs(x[1]-a));
    //printf("%lld\n",t[1].d[0]);
    //printTable(n);
    for(int i = 2; i <= q; i++){
        SegmentT left = segAsk(1,1,x[i]);
        long long offer = left.d[1]+x[i];
        if(x[i]+1<=n){
            SegmentT right = segAsk(1,x[i]+1,n);
            long long cur = right.d[2]-x[i];
            if(offer>cur) offer = cur;
        }
        segChange(1,1,n,abs(x[i]-x[i-1]));
        pointChange(1,x[i-1],offer);
        //printTable(n);
        //printf("curAns: %lld\n",t[1].d[0]);
    }   
    printf("%lld\n",t[1].d[0]);
    return 0;
}


Measured memory_bytes: 34528
n, m, k = map(int, input().split())
MOD = 998244353
class Combination:
    def __init__(self, N=5*10**5, mod=MOD):
        self.mod = mod
        self.N = N
        self.fact = [1, 1]  # fact[n] = (n! mod p)
        self.factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
        self.inv = [0, 1]  # factinv 計算用
        for i in range(2, N + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)
    def nCr(self, n, r):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.mod

comb = Combination(2 * 10**5)
ans = 0
for i in range(k+1):
    ans += m * pow(m-1, n-1-i, MOD) * comb.nCr(n-1, i)
    ans %= MOD
print(ans)

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int n;
    cin >> n;

    while( n > 0 ) {
        if ( ( n % 10 ) == 7 ) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }

    cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

struct node {
	struct node* right;
	struct node* left;
	struct node* parent;
	int key;
};
typedef struct node* Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x) {


}

Node treeMaximum(Node x) {


}
*/
Node treeSearch(Node u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;

}
/*
Node treeSuccessor(Node x) {


}
void treeDelete(Node z) {
	Node y; // node to be deleted
	Node x; // child of y

	

}
*/

void insert(int k) {
	Node y = NIL;
	Node x = root;
	Node z;

	z = (Node)malloc(sizeof(struct 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) {
		inorder(u->left);
		printf(" %d", u->key);
		inorder(u->right);
	}
}

void preorder(Node u) {
	if (u != NIL) {
		printf(" %d", u->key);
		preorder(u->left);
		preorder(u->right);
	}
}


int main() {
	int  i, x, n;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", com);
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i') {
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd') {
			scanf("%d", &x);
			//treeDelete(treeSearch(root, x));
		}

	}

	return 0;
}


Measured memory_bytes: 20612
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL =long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 9; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[800][10][2], a[200000], b[200000];
string str, ss;
bool f;
char c[800][800];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<Edge>vec[20000];
vector<edge>ed;
vector<LL>v;
map<string,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> str;
	ss = "keyence";
	
	while (str[cnt] == ss[cnt]) {
		cnt++;
		if (cnt >= str.size())break;
	}
	while (str[str.size()-1-last]==ss[ss.size()-1-last]) {
		last++;
		if (last >= str.size())
			break;
	}
	if (cnt + last >= ss.size())
		cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 768
function is_prime(n)
	for i=2,math.sqrt(n)do
		if n%i==0 then return false end
	end
	return true
end
n=io.read("*n")
cnt=0
for i=2,2000 do
	if cnt==n then break end
	if is_prime(i)and i%5==1 then
		if cnt~=0 then io.write" "end
		io.write(i)
		cnt=cnt+1
	end
end

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    n =int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    sum = 0
    for i in range(n):
        c = a[i]-b[i]
        if c > 0:
            sum+=c


    print(sum)


Measured memory_bytes: 5144
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define INF (1<<30)
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n;
	while (cin >> n, n) {
		vector<ll> a(n);
		vector<ll> Sum(n+1);
		for (int i = 0; i < n; i++) cin >> a[i];
		Sum[0] = 0;
		for (int i = 1; i <= n;i++) Sum[i] = a[i-1] + Sum[i - 1];

		ll ans = -INF;

		for (int i = 0; i < n;i++) {
			for (int j = i + 1;j <= n;j++) {
				ans = max(ans,Sum[j] - Sum[i]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3244
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC163
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var m = NextInt();
            var aas = ReadIntArray();

            var sum = aas.Sum();

            if (sum > n)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(n - sum);
            }
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


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

int main() {
  int n; cin >> n;
  int counter = 0, a[110];
  for(int i = 0; i < n; i++) cin >> a[i];

  //--- Selection Sort ---//
  for(int i = 0; i < n; i++) {
    //--- 未探索の先頭を minj にしておく ---//
    int minj = i;
    //--- 未探索部分の最小を探す ---//
    for(int j = i; j < n; j++) {
      if(a[j] < a[minj]) minj = j;
    }
    //--- 未探索部分の先頭よりも小さいものが見つかった場合 ---//
    if(i != minj) {
      swap(a[i], a[minj]);
      counter++;
    }
  }

  for(int i = 0; i < n; i++) cout << a[i] << (i == n-1 ? "\n" : " ");
  cout << counter << endl;
}



Measured memory_bytes: 3088
n = int(input())
l = list(map(int,input().split()))
ll = sorted(l)
med1 = ll[n//2-1]
med2 = ll[n//2]
if med1 == med2:
    for i in range(n):
        print(med1)
else:
    for i in range(n):
        if l[i] <= med1:
            print(med2)
        else:
            print(med1)

Measured memory_bytes: 93652
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
int main(){
    string s,t;
    bool fl = true;
    cin >> s >> t;
    int n = s.size();
    rep(i,n){
        rep(j,n){
            if(s[(i+j)%n] != t[j]){
                fl = false;
                break;
            }
        }
        if(fl){
            cout << "Yes" << endl;
            fl = false;
            break;
        }
        fl = true;
    }
    if(fl){
        cout << "No" << endl;
    }
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())

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

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

  string s; cin >> s;
  sort(s.begin(), s.end());

  if(s == "abc") {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for(int i=1;i<=n;i++){
			System.out.println("Case " + i + ":");
			int m = sc.nextInt();
			for(int j=0;j<10;j++){
				m = (m*m/100)%10000;
				System.out.println(m);
			}	
		}
	}	
}

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


int main(){
    int N;
    int B[100];
    cin >> N;
    for(int i=0; i<N-1; i++){
        cin >> B[i];
    }

    int A[100];

    A[0] = B[0];
    A[1] = B[0];

    for(int j=1; j<N-1; j++){
        if(B[j] < B[j-1]){
            A[j] = B[j];
        }
        A[j+1] = B[j];
    }

    int sum = 0;

    for(int k=0; k<N; k++){
        sum += A[k];
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int n,k;
int a[200005],maxx,minn,num=0;
bool flags=1;
long long ans=1;
long long ksm(long long x,long long n)
{
	long long ans=1;
	while(n)
	{
		if(n&1) ans=ans*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return ans;
}
bool cmp(int x,int y)
{
	return abs(x)>abs(y);
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) if(a[i]>=0) flags=0;
	sort(a+1,a+n+1,cmp);
	if(flags)
	{
		if(k&1) for(int i=n;i>=n-k+1;i--) ans=ans*a[i]%mod;
		else for(int i=1;i<=k;i++) ans=ans*a[i]%mod;
		ans=(ans%mod+mod)%mod;
		printf("%lld\n",ans);
		return 0;
	}
	if(n==k)
	{
		ans=1;
		for(int i=1;i<=k;i++) ans=ans*a[i]%mod;
		ans=(ans%mod+mod)%mod;
		printf("%lld\n",ans);
		return 0;
	}
	ans=1;
	for(int i=1;i<=k;i++)
	{
		ans=ans*a[i]%mod;
		if(a[i]<0) num++,maxx=a[i];
		if(a[i]>0) minn=a[i];
	}
	if(!ans)
	{
		printf("%lld\n",ans);
		return 0;
	}
	if(!(num&1)) printf("%lld\n",ans);
	else
	{
		long long u=0,v=0,u2=0,v2=0;
		v=-maxx,v2=minn;
		for(int i=n;i>k;i--)
		if(a[i]>0) u=a[i];
		else u2=-a[i];
		if(!v2) ans=ans*ksm(-v,mod-2)%mod*u%mod;
		else
		{
			if(u*v2>u2*v) ans=ans*ksm(-v,mod-2)%mod*u%mod;
			else ans=ans*ksm(v2,mod-2)%mod*-u2%mod;
		}
		ans=(ans%mod+mod)%mod;
		printf("%lld\n",ans);
	}
}

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

int n, A;
bitset<N*N> S;

int main(){
  
  cin>>n;
  
  int sum=0;
  
  S=1;
  
  for(int i=0;i<n;i++){
    cin>>A;
    S|=S<<A;
    sum+=A;
  }
  
  int num=ceil(sum/2.0);
  
  for(int i=num;i<=sum;i++){
    if(S[i]==1){
      cout<<i<<endl;
      return 0;
    }
    /*    if(((S>>i)&bitset<N*N>(1))==1){
      cout<<i<<endl;
      return 0;
      }*/
  }
  
  return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
//#define _CRT_INT_MAX
#define _CRT_INT_MAX 2147483647
int main(){
    int n;
    scanf("%d",&n);
    int h[100001];
    int i;
    for(i=1;i<=n;i++){
        scanf("%d",&h[i]);
    }
    h[n+1] = _CRT_INT_MAX;
    int j = 1;
    int count=0;
    while(1){
        i=0;
        while(1){
            if(h[j+i]>=h[j+i+1]){
               // printf("true\n");
                i++;
            }
            else{
               // printf("false\n");
                if(count<i){
                count = i;
                }
                j = j+i+1;
                break;
            }

        }
        if(j>n){
            break;
        }
    }
    printf("%d\n",count);
    return 0;
}

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

int main(){
    int n,i;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        long long p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
//        for (map<int,long long>::iterator it=m.begin(); it!=m.end(); ++it){
//            if(it->second>=1000000){
//                s=1;
//                cout<<it->first<<endl;
//            }
//        }
        for (int i=0;i<vec.size();i++){
            map<int,long long>::iterator it=m.find(vec[i]);
            if(it->second>=1000000){
                s=1;
                cout<<it->first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1292