akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  readln.chomp.replace(",", " ").writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<ll>t(n),a(n);
  rep(i,n) cin >> t[i];
  rep(i,n) cin >> a[i];
  
  vector<ll>h(n);
  
  h[0]=t[0];
  rep(i,n-1){
    if(t[i]<t[i+1])h[i+1]=t[i+1];
  }
  bool ok = true;
  if(h[n-1]!=0 && h[n-1]!=a[n-1])ok=false;
  h[n-1]=a[n-1];
  
  rep(i,n-1){
    if(a[n-1-i]<a[n-1-(i+1)] && h[n-1-(i+1)]==0)h[n-1-(i+1)]=a[n-1-(i+1)];
  }
  ll ans = 1;
  ll ma = 0;
  rep(i,n){
    if(h[i]==0){
      ans*=min(a[i],t[i]);
      ans%=MOD;
      h[i]=min(a[i],t[i]);
    }
  }
  rep(i,n){
    if(ma<h[i])ma=h[i];
    if(ma!=t[i])ok=false;
  }
  ma=0;
  rep(i,n){
    if(ma<h[n-1-i])ma=h[n-1-i];
    if(ma!=a[n-1-i])ok=false;
  }
  if(!ok)ans=0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5576
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = 1 << 12;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    while (1) {
        int n,a[1001];
        cin >> n;
        if(n==0)break;
        REP(i,n)cin >> a[i];
        sort(a,a+n);
        int ans = 99999999;
        REP(i,n-1)ans = min(ans,a[i+1]-a[i]);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3124
#include <stdio.h>

int main(){
	int k, s;
	int total = 0;
	scanf("%i %i", &k, &s);
	for(int x=0; x <= k; x++){
		if (x>s){
			break;
		}
		for(int y=0; y <= k; y++){
			if ((x+y)>s){
				break;
			}
			if ((0<=(s-x-y))and((s-x-y)<=k)){
					total++;
			}
			
		}
	}
	printf("%i\n", total);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    Arr a(n + 1);
    forn(i, n + 1) cin >> a[i];
    Arr b(n);
    forn(i, n) cin >> b[i];
    ll cur = a[0];
    ll ans = 0;
    fori(i, 1, n + 1)
    {
        ll tot = cur + a[i];
        ans += min(tot, b[i - 1]);
        cur = max(a[i] - max(b[i - 1] - cur, 0LL), 0LL);
    }
    cout << ans;
    return 0;
}

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

int main(){
  int A, B, C, D, O, T;
  cin >> A >> B >> C >> D;
  O = C-B;
  T = A-D;
  if(O <= 0){
      cout << "Yes" << endl;
    }
  else if(T <= 0){
      cout << "No" << endl;
    }
  else if((O > 0) && (T >0)){
  for(; ;){
    O = O - B;
    if(O <= 0){
      cout << "Yes" << endl;
      break;
    }
    T = T - D;
    if(T <= 0){
      cout << "No" << endl;
      break;
    }
  }
  }
  return 0;
}

Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

// DAG - directed acyclic graph

const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax]; // the number of edges going to 'b'
int dist[nax];
bool visited[nax];

void dfs(int a) {
    assert(!visited[a]);
    visited[a] = true;
    for(int b : edges[a]) {
        dist[b] = max(dist[b], dist[a] + 1);
        --in_degree[b];
        if(in_degree[b] == 0) {
            dfs(b);
        }
    }
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    while(m--) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        ++in_degree[b];
    }
    for(int i = 1; i <= n; ++i) {
        if(!visited[i] && in_degree[i] == 0) {
            dfs(i);
        }
    }
    int answer = 0;
    for(int i = 1; i <= n; ++i) {
        answer = max(answer, dist[i]);
    }
    printf("%d\n", answer);
}


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

fun main(args: Array<String>) {
    val nums = readInts().map { it.toLong() }
    val K = readInts()[0]
    val max = nums.max()!!
    println(nums.sum() - max + (max shl K))
}

Measured memory_bytes: 36328
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL n; cin >> n;
	vector<LL> a(n);

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

	
	LL sum = 0;
	LL tmp1 = 0;
	for (int i = 0; i < n; i++) {
		//sumが正になるように調整
		if (i % 2 == 0) {
			sum += a[i];

			if (sum <= 0) {
				tmp1 += (1 - sum);
				sum = 1;
			}
		}
		//sumが負になるように調整
		else {
			sum += a[i];

			if (sum >= 0) {
				tmp1 += (sum + 1);
				sum = -1;
			}
		}
	}

	sum = 0;
	LL tmp2 = 0;

	for (int i = 0; i < n; i++) {
		//sumが正になるように調整
		if (i % 2 == 1) {
			sum += a[i];

			if (sum <= 0) {
				tmp2 += (1 - sum);
				sum = 1;
			}
		}
		//sumが負になるように調整
		else {
			sum += a[i];

			if (sum >= 0) {
				tmp2 += (sum + 1);
				sum = -1;
			}
		}
	}


	cout << min(tmp1,tmp2)<< endl;

	return 0;
}

Measured memory_bytes: 1024
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( "\n" );
  var rc = data[0].split( " " ).map( Number );
  var r = rc[0];
  var c = rc[1]; 
  var t = Array( c+1 );
  for( var i=0; i<c+1; i++ ) { t[i] = 0; }
  var output = [];
  for( var index=1; index<r+1; index++ ) {
    var nums = data[index].split( ' ' ).map( Number );
    var sum = 0;
    for( var j=0; j<c; j++ ) {
      sum += nums[j];
      t[j] += nums[j];
    }
    t[c] += sum;
    nums.push( sum );
    output.push( nums.join( " " ) );
  }
  output.push( t.join( " " ) );
  console.log( output.join( "\n" ) );
});

Measured memory_bytes: 10312
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N, K;
	cin >> N >> K;
	int ans = 0, in;
	for(int i = 0; i < N; i++){
		cin >> in;
		if(in >= K)ans++;
	}
	cout << ans << endl;

	return 0;
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const ll M = (ll)1e9 + 7;

vector<ll> fac(300001);
vector<ll> ifac(300001);

ll mpow(ll x, ll n) {
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b) {
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0) return 0;
    ll tmp = ifac[a - b] * ifac[b] % M;
    return tmp * fac[a] % M;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 300000; i++) {
        fac[i + 1] = fac[i] * (i + 1) % M;
        ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M;
    }
    FOR(i, 1, k) {
        ll devide_cnt = comb(k - 1, i - 1);
        ll ans = devide_cnt * comb(n - k + 1, i) % M;
        cout << ans << ln;
    }
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
  string s;
  cin >> s;
  for(int i = 0;i < s.size();i++){
        if(s[i] == '?'){
              s[i] = 'D';
        }
  }
  cout << s << endl;
}


Measured memory_bytes: 3724
ad = {}
mi = {}

n = int(input())
for i in range(n):
    s = input()
    n = ad.get(s, 0)
    n += 1
    ad[s] = n

n = int(input())
for i in range(n):
    s = input()
    n = mi.get(s, 0)
    n += 1
    mi[s] = n

res = 0
for k in ad.keys():
    val = ad[k]
    val -= mi.get(k, 0)
    res = max(res, val)

print(res)

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

int main()
{
    int H, W, CH, CW, DH, DW;
    cin >> H >> W >> CH >> CW >> DH >> DW;
    --CH;
    --CW;
    --DH;
    --DW;

    vector<string> S(H);
    for (int i=0;i<H;++i) { cin >> S[i]; }

    vector<int> Cost(H * W, 1000001);
    deque< pair<int, int> > Q;

    const auto insert = [&](int x, int y, int cost, int extraCost)
    {
        if (x < 0 || W <= x || y < 0 || H <= y) { return; }
        if (S[y][x] == '#') { return; }

        const auto newCost = cost + extraCost;
        if (Cost[x + y * W] <= newCost) { return; }
        Cost[x + y * W] = newCost;

        if (extraCost == 0) { Q.emplace_front(x, y); }
        else                { Q.emplace_back(x, y); }
    };

    insert(CW, CH, 0, 0);

    int ans = -1;

    while (!Q.empty())
    {
        const auto x = Q.front().first;
        const auto y = Q.front().second;
        Q.pop_front();

        const auto cost = Cost[x + y * W];
        if (x == DW && y == DH) { ans = cost; break; }

        insert(x - 1, y, cost, 0);
        insert(x + 1, y, cost, 0);
        insert(x, y - 1, cost, 0);
        insert(x, y + 1, cost, 0);

        for (int dx=-2;dx<=2;++dx)
        for (int dy=-2;dy<=2;++dy)
        {
            insert(x + dx, y + dy, cost, 1);
        }
    }

    cout << ans << endl;
}

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

void solve(std::istream& ist, std::ostream& ost)
{
    /* ------- 宣言と入力 ------- */

    int a;
    ist >> a;

    /* ------- 計算 ------- */

    ost << a + pow(a, 2)+pow(a,3) << endl;

}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif



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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


ll solve(ll A, ll B, ll C, ll X, ll Y) {
    if (X > Y) {
        swap(A,B); swap(X,Y);
    }
    // X <= Y
    ll w1 = A*X + B*Y;
    ll tw = C*2;
    ll w2 = tw*X + B*(Y-X);
    ll w3 = tw*Y;

    return min(min(w1,w2),w3);
}

int main() {
    int A,B,C,X,Y; cin >> A>>B>>C>>X>>Y;
    cout << solve(A,B,C,X,Y) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e4 + 5, M = 1e6 + 5;
const int inf = 1e18;
const int mod = 1e9 + 7;
int a[N], n, spf[M], mx[M], inv[M];
bool prime[M];

void pre(){
	fill(prime + 2, prime + M, true);
	for(int i = 2; i < M; i++){
		if(prime[i]){
			spf[i] = i;
			for(int j = 2*i; j < M; j += i)
				spf[j] = i, prime[j] = false;
		}
	}

	inv[0] = inv[1] = 1;
	int m = mod;
	for(int i = 2; i < M; ++i)
	    inv[i] = (m - (m/i) * inv[m%i] % m) % m;
}


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

    pre();

    cin >> n;
    for(int i = 1; i <= n; i++){
    	cin >> a[i];
    	int val = a[i];
    	while(val > 1){
    		int p = spf[val], cnt = 0;
    		while(val % p == 0)
    			++cnt, val /= p;
    		mx[p] = max(mx[p], cnt);
    	}
    }
    vector<pair<int,int>> LCM;
    for(int i = 2; i < M; i++)
    	if(mx[i] > 0)
    		LCM.push_back({i,mx[i]});

    int ans = 0;
    int val = 1;
    for(auto it : LCM){
    	int p = it.first, e = it.second;
    	for(int i = 0; i < e; i++)
    		val = val * p % mod;
    }

    for(int i = 1; i <= n; i++){
    	int add = val * inv[a[i]] % mod;
    	ans = (ans + add) % mod;
    }
    cout << ans << '\n';
}



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

int n;

int main()
{
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
    
    return 0;
}

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

void solve(long long N, std::vector<std::string> S)
{
    long long numAC = 0;
    long long numWA = 0;
    long long numTLE = 0;
    long long numRE = 0;

    for (auto s : S)
    {
        if (s == "AC")
        {
            ++numAC;
        }
        else if (s == "WA")
        {
            ++numWA;
        }
        else if (s == "TLE")
        {
            ++numTLE;
        }
        else if (s == "RE")
        {
            ++numRE;
        }
    }
    cout << "AC x " << numAC << endl;
    cout << "WA x " << numWA << endl;
    cout << "TLE x " << numTLE << endl;
    cout << "RE x " << numRE << endl;
}

// Generated by 1.1.7.1 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 N;
    scanf("%lld", &N);
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6428
#include <cmath>
#include <iostream>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int N, X;
	cin >> N >> X;
	int ans = -1;
	for (int i = 0; i < N; ++i) {
		int p;
		cin >> p;
		p = abs(X - p);
		if (ans == -1) ans = p;
		else ans = gcd(ans, p);
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;

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

    vector<int> P(N, 0);
    vector<int> Q(N, 0);

    for (int i = 0; i < N; i++) {
        cin >> P.at(i);
    }

    for (int i = 0; i < N; i++) {
        cin >> Q.at(i);
    }

    vector<int> v(N, 0);
    for (int i = 0; i < N; i++) {
        v.at(i) = i+1;
    }

    int idx = 0;
    int a = -1;
    int b = -1;
    do {
        bool ok = true;

        for (int i = 0; i < N; i++) {
            if (P.at(i) != v.at(i)) ok = false;
        }

        if (ok) a = idx;

        ok = true;
        for (int i = 0; i < N; i++) {
            if (Q.at(i) != v.at(i)) ok = false;
        }

        if (ok) b = idx;

        idx++;
    } while(next_permutation(v.begin(), v.end()));

    int ans = abs(a - b);
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    rep2(i, 1, n+1)
    {
        if ((int)(i * 1.08) == n)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split(" ")))

graph = [list() for i in range(N+1)]

for i in range(M):
    a, b = list(map(int, input().split(" ")))
    graph[a].append(b)
    graph[b].append(a)
    
def DFS(node, prev, visited):
    visited.append(node)
    if len(visited) == N:
        return 1
    
    res = 0
    for edge in graph[node]:
        if edge == prev:
            continue
        elif edge in visited:
            continue
        res += DFS(edge, node, visited[:])
        
    return res

print(DFS(1, 0, []))

Measured memory_bytes: 3064
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                if ((input[0] == "0") && (input[1] == "0")) return;
                var x = int.Parse(input[0]);
                var y = int.Parse(input[1]);
                if (x <= y)
                {
                    Console.WriteLine("{0} {1}",x,y);
                }
                else
                {
                    Console.WriteLine("{0} {1}", y, x);
                }
            }
        }
    }
}

Measured memory_bytes: 5772
#include <iostream>

int root(int* par, int x)
{
	if (par[x] == x) return x;
	else return root(par, par[x]);
}

bool isSame(int* par, int x, int y)
{
	return root(par, x) == root(par, y);
}

void unite(int* par, int x, int y)
{
	par[root(par, y)] = root(par, x);
}

int main()
{	
	int n, q; std::cin >> n >> q;
	
	int* parent = new int[n];
	for (int i=0; i<n; i++) parent[i] = i;

	for (int i=0; i<q; i++) {
		int op, x, y;
		std::cin >> op >> x >> y;
		if (op==0) {
			unite(parent, x, y);
		} else {
			std::cout << isSame(parent, x, y) << std::endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int rc=0;
  int ans=0;
  cin>>N;
  vector<char> C(N);
  for(int i=0;i<N;i++){
    cin>>C.at(i);
    if(C.at(i)=='R')rc++;
  }
  for(int i=0;i<rc;i++){
    if(C.at(i)=='W')ans++;
  }
  cout<<ans<<endl;
}

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

void dump(const vector<int>& vec) {
	cout << vec[0];
	for (int i = 1; i < vec.size(); ++i)cout << " " << vec[i];
	cout << endl;
}

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	dump(A);
	for (int i = 1; i < N; ++i) {	
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			--j;
		}
		A[j + 1] = v;
		dump(A);
	}
	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int H, W;
string A[1010];
int vis[1010][1010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> W;
	rep(y, 0, H) cin >> A[y];

	queue<pair<int, int>> que;
	rep(y, 0, H) rep(x, 0, W) if (A[y][x] == '#') {
		vis[y][x] = 1;
		que.push({ x,y });
	}

	int ans = 0;
	while (!que.empty()) {
		queue<pair<int, int>> que2;

		while (!que.empty()) {
			int x, y;
			tie(x, y) = que.front(); que.pop();

			rep(d, 0, 4) {
				int xx = x + dx[d];
				int yy = y + dy[d];
				if (xx < 0 or W <= xx or yy < 0 or H <= yy) continue;
				if (!vis[yy][xx]) {
					vis[yy][xx] = 1;
					que2.push({ xx,yy });
				}
			}
		}

		swap(que2, que);
		ans++;
	}
	cout << ans-1 << endl;
}



Measured memory_bytes: 13456
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[1 for i in range(n+1)] for j in range(m+1)]
ans=1
mod=10**9+7
for T in range(1,m+1):
    for S in range(1,n+1):
        tmp=dp[T-1][S-1]
        if(s[S-1]==t[T-1]):
            dp[T][S]=(dp[T-1][S]+dp[T][S-1])%mod
        else:
            dp[T][S]=(dp[T-1][S]+dp[T][S-1]-tmp)%mod
print(dp[-1][-1])

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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

const int N = 1e5 + 123;
int n, a[N];
vi adj[N];

void dfs(int v, int p) {
	int child = 0;
	for (int to : adj[v]) {
		if (to == p) {
			continue;
		}
		dfs(to, v);
		if (adj[to].size() == 1) {
			a[to] = 1;
		}
		child += a[to];
	}
	if (child >= 2) {
		cout << "First";
		exit(0);
	}
	if (child == 1) {
		a[v] = 0;
	}	else {
		a[v] = 1;
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs(1, 1);
	if (a[1] == 1) {
		cout << "First";
	}	else {
		cout << "Second";
	}
}


Measured memory_bytes: 6144
def isprime(n):
    if(n==2 or n==3):
        return True
    if(n<=1):
        return False
    if(n%2==0 or n%3==0):
        return False
    x=5
    while(x*x<=n):
        if(n%x==0 or n%(x+2)==0):
            return False
        x+=6
    return True
n,p=map(int,input().split())
if(n==1):
    print(p)
else:
    ans=1
    for i in range(2,int(p**0.5)+1,1):
        num=p
        count=0
        while(num%i==0):
            num=num//i
            count+=1
        if(count>=n):
            ans=i
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a[200000];
    int k, n;
	cin >> k >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int x = (k + a[0]) - a[n - 1];
    for (int i = 0; i < n - 1; i++) {
        x = max(x, a[i + 1] - a[i]);
    }

    cout << k - x << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  int N, M, ansF, cou;
  cin >> N >> M;
  ansF = cou = 0;
  int ans[N], count[N], s[M], c[M];
  rep (i, N) ans[i] = count[i] = 0;
  rep (i, M) cin >> s[i] >> c[i];
  for (int i = 0; i < M; ++i) {
    ans[s[i]-1] = c[i];
    ++count[s[i]-1];
    for (int j = 0; j < i; ++j) {
      if (s[i] == s[j]) {
        if (c[i] != c[j]) {
          cou = 1;
        }
      }
    }
  }
  if (count[0] == 0) {
    ans[0] = 1;
  }
  if (cou == 1) {
    ansF = -1;
  } else {
    ansF = 0;
    for (int i = 0; i < N; ++i) {
      int tmp = 0;
      if (N == 3) {
        if (i == 2) {
          tmp = 1;
        } else if (i == 1) {
          tmp = 10;
        } else {
          tmp = 100;
        }
      } else if (N == 2) {
        if (i == 1) {
          tmp = 1;
        } else {
          tmp = 10;
        }
      } else {
        tmp = 1;
      }
      // printf("%d\n", ans[i]);
      // printf("%d\n", tmp);
      ansF += ans[i] * tmp;
    }
  }
  // printf("%d\n", ansF);
  if (N == 1 && (ansF > 9 || ansF < 0)) {
    cou = 1;
  } else if (N == 2 && (ansF < 10 || ansF > 99)) {
    cou = 1;
  } else if (N == 3 && (ansF < 100 || ansF > 999)) {
    cou = 1;
  }
  if (N == 1 && M == 0) {
    ansF = 0;
  }
  if (cou == 1) {
    ansF = -1;
  }
  printf("%d\n", ansF);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String line = sc.next();
        int a = Integer.parseInt(line.substring(0,1));
        int b = Integer.parseInt(line.substring(1,2));
        int c = Integer.parseInt(line.substring(2,3));
        System.out.println(a+b+c);
    }
}

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

int main() {
    ll x, y;
    cin >> x >> y;

    ll ans = 0;
    while (x <= y) x *= 2, ans++;

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


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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

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

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

Measured memory_bytes: 768
N = int(raw_input())

for h in range(1,3500):
  for w in range(h,3500):
    if (4*h*w-N*w-N*h) < 1:
      continue
    if (N*h*w % (4*h*w-N*w-N*h)) == 0:
      print h,w,(N*h*w / (4*h*w-N*w-N*h))
      exit(0)


Measured memory_bytes: 2820
use std::collections::HashMap;

fn main() {
    let n = read::<u32>();
    let mut words: Vec<String> = Vec::new();
    for _ in 0..n {
        words.push(read());
    }

    let mut dict: HashMap<String, u32> = HashMap::new();
    let mut max = 0;
    for word in words.iter() {
        let d = dict.get(word);
        let new_count = match d {
            Some(i) => i + 1,
            None => 1,
        };
        if new_count > max {
            max = new_count;
        }
        dict.insert(String::from(word), new_count);
    }

    let mut max_words: Vec<_> = dict
        .iter()
        .filter(|&(k, v)| v == &max)
        .map(|(k, v)| k)
        .collect();
    max_words.sort();

    for word in &max_words {
        println!("{}", word);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


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

int main() {
    int n; cin >> n;
    vector<int> x(n);
    int minv, maxv;
    rep(i, n) {
        cin >> x.at(i);
        if (i == 0) {
            minv = x.at(i);
            maxv = x.at(i);
        }
        minv = min(minv, x.at(i));
        maxv = max(maxv, x.at(i));
    }

    int ans;
    for (int i = minv; i <= maxv; i++) {
        int sum = 0;

        rep(j, n) {
            sum += (abs(x.at(j) - i) *abs(x.at(j) - i));
        }

        if (i == minv) {
            ans = sum;
        }
        else {
            ans = min(ans, sum);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int n, a[200010], b[200010];
int main() {
	ll ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i] - (i + 1);
	}
	sort(b, b + n);
	int f = b[(n - 1) / 2];
	for (int i = 0; i < n; i++)ans += abs(a[i] - (i + 1) - f);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 303, mod = 1e9 + 7;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	double s = 0;
	vector<int> a(n);
	for(auto &i : a) cin >> i, s += i;
	s /= n;
	int id = 0;
	for(int i = 1; i < n; i++) if(abs(a[i]-s) < abs(a[id]-s)) id = i;
	cout << id << '\n';
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 1005;
vector<int> primes;
void pre() {
	vector<bool> pri(N,1);

	for(int i = 4; i < N; i += 2) pri[i] = 0;

	for(int i = 3; i * i < N; i += 2) {
		if(!pri[i])
			continue;
		for(int j = i * i; j < N; j += i)
			pri[j] = 0;
	}
	repA(i,2,N-1)
		if(pri[i])
			primes.pb(i);
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
    int n,a,b;
    cin >> n >> a >> b;

    vector<int> x(n);
    rep(i,n)
    	cin >> x[i];
    
    int ans = 0;
    int st = x[0];
    repA(i,1,n-1) {
    	if((x[i] - st) * a > b)
    		 ans += b;
    	else
    		ans += (x[i] - st) * a;
    	st = x[i];
    }
    cout << ans << '\n';
}

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

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll cntR = 0;
    ll cntG = 0;
    ll cntB = 0;
    for(ll i=0; i<N; i++){
        if(S[i] == 'R'){
            cntR++;
        }else if(S[i] == 'G'){
            cntG++;
        }else{
            cntB++;
        }
    }

    ll cntE = 0;
    for(ll i=1; i<=N; i++){
        for(ll j=i+1; j<=N; j++){
            ll k = 2*j-i;
            if(k <= N){
                if(S[i-1] != S[j-1] && S[i-1] != S[k-1] && S[j-1] != S[k-1]){
                    cntE++;
                }
            }
        }
    }
    cout << cntR*cntG*cntB - cntE << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

typedef long long ll;

ll num[100005];

int main(){

	int N;

	ll K;

	scanf("%d %lld",&N,&K);

	int i;

	int a, b;

	for (i = 0; i < N; i++) {
		scanf("%d %d",&a,&b);
		num[a] += b;
	}

	ll ans = 0ll;
	for (i = 1; i <= 100000; i++) {
		if (num[i] > 0ll) {
			if (ans + 1ll<=K && K<=ans + num[i]) {
				printf("%d\n",i);
				return 0;
			}
			ans += num[i];
		}
	}

	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 3104
#include<stdio.h>
#define fup(i,a,b) for(int i=a;i<b;++i)
#define fdn(i,a,b) for(int i=a;i>=b;--i)
#define mem(a,b) memset(a,b,sizeof(a))

void Main()
{
    int n;char a[105];
    scanf("%d %s",&n,a);
    int b[103][2],cz[130],cy[130];
    int s,sz,sy;
    fup(x,0,n)
    {
        sz=sy=s=0;
        mem(cz,0);mem(cy,0);
        fdn(i,x,0)++cz[a[i]];
        fup(i,x+1,n)++cy[a[i]];
        fup(i,95,130)
        {
            if(cz[i])++sz;
            if(cy[i])++sy;
            if(cz[i]&&cy[i])++s;
        }
        b[x][0]=sz+sy;
        b[x][1]=s;
    }
    int mx=-1,j=0;
    fup(i,0,n)if(mx<b[i][0])mx=b[i][0],j=i;
    printf("%d",b[j][1]);
}
int main()
{
Main();
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
ll x[1005], y[1005], z[1005];

ll calc(ll a, int p) {
  if(p == 0) return a;
  else return -a;
}

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

  cin >> n >> m;
  REP(i, n) cin >> x[i] >> y[i] >> z[i];

  ll ans = -LLINF;
  REP(i, 2) REP(j, 2) REP(k, 2) {
    vector<ll> v;
    REP(l, n) {
      ll sum = 0;
      sum += calc(x[l], i);
      sum += calc(y[l], j);
      sum += calc(z[l], k);
      v.push_back(sum);
    }

    sort(v.begin(), v.end(), greater<ll>());
    ll tmp = 0;
    REP(l, m) tmp += v[l];
    ans = max(ans, tmp);
  }

  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
#define em emplace_back

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	string s;
	cin >> n >> s;
	ll ans = 0, z =0;
	for (const auto& x : s)
		if (x == 'R')
			z++;
	for (ll i=0; i<z; i++)
		if (s[i] == 'R')
			ans--;
	ll res = (ans+z);
	z = (n-z);
	ans = 0;
	for (ll i=0, j = n-1; i<z; i++, j--)
		if (s[j] == 'W')
			ans--;
	res = min(res, ans+z);
	cout << res<< '\n';
	return 0;
}


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

int main() {
    int a,b,c;
    cin >> a >> b >>c;
    if(a==b && b==c){cout << "No";
    return 0;}
    else if(a==b||b==c||c==a){cout << "Yes";
    return 0;}
    else{cout << "No";}
}


Measured memory_bytes: 256
N = int(input())

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

for a in range(N):
    A[a] -= 1


cnt = 0
cnt += B[int(A[0])]

pa = A[0]

for a in A[1:N+1]:
    cnt += B[int(a)]

    if (a-1) == pa:
        cnt += C[int(a-1)]
    pa = a

print(cnt)


Measured memory_bytes: 3064
#include<stdio.h>

int n, k, step;
int a[100];
int i;

int binary_search(int x) {
	int l = 0, middle = 0, h = n - 1;

	while (l <= h) {
		middle = (l + h) / 2;
		step++;
		if (a[middle] == k) {
			return 1;
		}
		else if (a[middle] > k) {
			h = middle - 1;
		}
		else {
			l = middle + 1;
		}
	}
	return -1;
}

int main(void) {
	
	while (1) {
		scanf("%d", &n);
		if (n == 0)break;
		step = 0;
		for (i = 0; i < n; i++)
			scanf("%d",&a[i]);
		scanf("%d",&k);

		binary_search(k);
		printf("%d\n",step);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    string s;
    int count=0;

    cin>>s;
    
    FOR(i,0,s.size()-1){
        if(s[i]!=s[s.size()-1-i]){
            s[i]=s[s.size()-1-i];
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
n = int(input())
ans = 10000
for i in range(1, n):
    X = list(str(i))
    Y = list(str(n - i))
    m = 0
    for j in X:
        m+=int(j)
    for k in Y:
        m+=int(k)
    if(m < ans):
        ans = m
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python
# coding: utf-8

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def main():
    N, M = list(map(int, input().split()))
    k = M // N
    divisors = make_divisors(M)
    print([d for d in divisors if d <= k][-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.Scanner;

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

    int totalAttack = 0;

    for (int i = 0; i < attacks; i++) {
      totalAttack += sc.nextInt();
    }
    if (health > totalAttack)
      System.out.println("No");
    else
      System.out.println("Yes");
  }
}

Measured memory_bytes: 49836
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;
 
 
int main(){
 
	int a,b,c;
	cin >> a >> b >> c;
	
	if(c-(a-b)<0){
		cout << 0 << endl;
	}else{
		cout << c-(a-b) << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=jp

#define MAX 505
int A[MAX];
int N;

static int selection() {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i+1; j < N; j++) {
            if (A[minj] > A[j]) {
                minj = j;
            }
        }
        if (minj != i) {
            swap(A[minj], A[i]);
            cnt++;
        }
    }
    return cnt;
}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    int c = selection();
    arrdump(N, A);
    cout << c << "\n";

    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int getDigitSum(int x);

int getAbs(int x);

int getMin(vector<int> v);

int main(){
    char x, y;
    cin >> x >> y;

    string ans = (x < y)? "<" : (x == y)? "=" : ">";
    cout << ans << endl;
    return 0;
}

int getDigitSum(int x){
    int res = 0;
    while(x > 0){
        res += x % 10;
        x /= 10;
    }
    return res;
}

int getAbs(int x){
    return (x > 0)? x : -x;
}

int getMin(vector<int> v){
    int res = 40000;
    for(int i = 0; i < v.size(); i++){
        res = min(res, v[i]);
    }
    return res;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N = 0;

    cin >> N;

    int64_t ans = 0;

    for(int i = 1; i <= N; i++){
        if((i % 3) != 0){
            if((i % 5) != 0){
                ans += i;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(void)
{
  int a,b,c;
  int result = 0;
  
  cin >> a >> b >> c;
  
  if(a == 7)
    if(b == 5 && c == 5)
      result = 1;
  
  if(b == 7)
    if(a == 5 && c == 5)
      result = 1;
  
  if(c == 7)
    if(a == 5 && b == 5)
      result = 1;

  if(result == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    ll ans = 0;
    bool p = true;
    rep(i, 0, n){
        if(i==0){
            if(a[i]==b[i]){
                ans += 3;
            }else{
                ans += 6;
                p = false;
                i++;
            }
            continue;
        }
        if(a[i]!=b[i]){
            if(p){
                ans *= 2;
                ans %= mod;
            }else{
                ans *= 3;
                ans %= mod;
            }
            i++;
            p = false;
        }else{
            if(p){
                ans *= 2;
                ans %= mod;
            }
            p = true;
        }
    }
    cout << ans%mod << endl;
}

Measured memory_bytes: 3592
# B - Grid Compression
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]

# 横方向を調べる
for i in reversed(range(H)):
        if a[i].count(".") == W:
            a.pop(i)

# 抜けた分、縦の長さを再定義する
H = len(a)

# 縦方向を調べる
for i in reversed(range(W)):
    for j in range(H):
        if a[j][i] == ".":
            pass
        else:
            break
    else:
        for j in range(H):
            a[j].pop(i)

# 出力
for i in range(H):
    a[i] = "".join(a[i])
    print(a[i])


Measured memory_bytes: 9244
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int N,K;
	char S[50];
	cin >> N >> K;
	cin >> S;
	if (S[K-1] == 'A')
	{
		S[K-1] = 'a';
	}
	else if (S[K-1] == 'B')
	{
		S[K-1] = 'b';		
	}
	else if (S[K-1] == 'C')
	{
		S[K-1] = 'c';		
	}

	cout << S << endl;
	return 0;
}

Measured memory_bytes: 888