akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    char alpha;
    cin >> alpha;
    if(alpha<91) cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

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

  int maxv = 0;
  int cntv = 0;
  rep(i, s.size())
  {
    if(s[i] == 'A'
    || s[i] == 'G'
    || s[i] == 'C'
    || s[i] == 'T')
    {
      cntv++;
      maxv = max(maxv, cntv);
    }
    else
    {
      cntv = 0;
    }
    
  }

  cout << fixed << maxv << endl;

  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cmath>
using namespace std;
 
int main(){
  long long H,ans,k=0;
  cin>>H;
  while(H!=0){
    H=H/2;
    k++;
  }
  for(int i=0;i<k;i++){
    ans+=pow(2,i);
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int kiyaku(int n) {
	int ans = n;
	for (int i = 2; i <= n; i++) {
		if (prime(i)) {
			if (n%i == 0) {
				ans /= i;
				ans *= (i - 1);
			}
		}
	}
	return ans;
}
/*Library End!*/
int n;
double a[105],ans=100000.,hei,memo[105];
signed main() {
	cin>>n;
	double cnt=0.;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	hei=cnt/n;
	for(int i=0;i<n;i++){
		memo[i]=abs(hei-a[i]);
		ans=min(ans,memo[i]);
	}
	for(int i=0;i<n;i++){
		if(ans==memo[i]){
			cout<<i<<endl;
			return 0;
		}
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> iP;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = 99999999;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
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 (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    int n,k,sum;
    cin >> n >> k;
    REP(i,n){
        int x;
        cin >> x;
        sum += min(abs(x)*2,abs(x-k)*2);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

tmp = 10000
i = 0
for index, h in enumerate(H):
    ond = T - h * 0.006
    diff = abs(ond - A)
    if diff < tmp:
        tmp = diff
        i = index + 1

print(i)


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

using namespace std;

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

typedef complex<double> P;
typedef vector<P> Polygon;

double const EPS = 1e-7;
double const inf = 1e10;

struct Line : public vector<P>
{
  Line() {}
  Line(P const& a, P const& b) {
    push_back(a), push_back(b);
  }
  P vectorize() { return (*this)[1]-(*this)[0]; }
  double length() { return abs((*this)[1]-(*this)[0]); }
};

inline double dot(P const& a, P const& b) { return real(conj(a)*b); }
inline double cross(P const& a, P const& b) { return imag(conj(a)*b); }

enum { counter_clockwise = +1, clockwise = -1, cab_online = +2, abc_online = -2, on_segment = 0 };
int ccw(P a, P b, P c) {
  b -= a, c -= a;
  if(cross(b, c) > 0) return counter_clockwise;
  if(cross(b, c) < 0) return clockwise;
  if(dot(b, c) < 0) return cab_online;
  if(norm(b) < norm(c)) return abc_online;
  return on_segment;
}

typedef Line Segment;


P crosspoint(Line const& l, Line const& m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  if(abs(A) < EPS && abs(B) < EPS) { return m[0]; } // same line
  if(abs(A) < EPS) { return P(inf, inf); }
  return m[0] + B / A * (m[1]-m[0]);
}

// Notice: Return left part of the polygon.
Polygon convex_cut(Polygon const& G, Line const& l) {
  Polygon left_part;
  rep(i, G.size()) {
    P const& a = G[i], b = G[(i+1)%G.size()];
    Line const& ab = Line(a, b);
    if(ccw(l[0], l[1], a) != clockwise) { left_part.push_back(a); }
    if(ccw(l[0], l[1], a) * ccw(l[0], l[1], b) < 0) {
      P r = crosspoint(ab, l);
      if(r == P(inf, inf)) { continue; }
      left_part.push_back(r);
    }
  }
  return left_part;
}

// Notice: The border of the polygon in counterclockwise order.
bool able_polygon(Polygon const& G, double x) {
  int N = G.size();
  Polygon A = {{-inf, -inf}, {inf, -inf}, {inf, inf}, {-inf, inf}};
  rep(i, N) {
    Line ln(G[i], G[(i+1)%N]);
    P shift = ln.vectorize()*polar(x/ln.length(), M_PI/2.);
    A = convex_cut(A, Line(G[i] + shift, G[(i+1)%G.size()] + shift));
  }
  return !A.empty();
}

double solve(Polygon const& G) {
  double L = 0., R = inf;
  rep(loop, 1000) {
    double M = (L+R) / 2.;
    if(able_polygon(G, M)) { L = M; }
    else { R = M; }
  }
  return L;
}

int main() {
  
  int N;
  while(cin >> N && N) {
    Polygon G(N);
    rep(i, N) {
      double x, y; cin >> x >> y;
      G[i] = P(x, y);
    }
    printf("%.8f\n", solve(G));
  }
  return 0;
}

Measured memory_bytes: 1268
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
#include <set>
#include <iomanip>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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

int main()
{
    int t,p,r;
    while((cin >> t >> p >> r )&&t && p && r){
        int wrong[10][50] = {0};
        int tID,pID,time;
        int ansID[50];
        string msg;
        int memo[50] = {0};
        
        int cnt[50] = {0};
        
        for(int i=0;i<r;i++){
            cin >> tID >> pID >> time >> msg;
            if(msg == "WRONG"){
                wrong[pID-1][tID-1]++;
            }else if(msg == "CORRECT"){
                memo[tID-1] += wrong[pID-1][tID-1] * 1200 + time;
                cnt[tID-1]++;
            }else{

            }
        }
        for(int i=0;i<t;i++){
            ansID[i] = i+1;
        }
        
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(cnt[i] < cnt[j]){
                    swap(ansID[i],ansID[j]);
                    swap(cnt[i],cnt[j]);
                    swap(memo[i],memo[j]);
                }
                
                else if(cnt[i] == cnt[j]){
                    if(memo[i] > memo[j]){
                        swap(ansID[i],ansID[j]);
                        swap(cnt[i],cnt[j]);
                        swap(memo[i],memo[j]);
                    }else if(memo[i] == memo[j] && ansID[i] > ansID[j]){
                        swap(ansID[i],ansID[j]);
                        swap(cnt[i],cnt[j]);
                        swap(memo[i],memo[j]);
                    }
                }
            }
        }

        
        for(int i=0;i < t;i++){
            cout << ansID[i] << " " << cnt[i] <<" " << memo[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m, price, k, bit;
    cin >> n >> m;
    unordered_map<int, int> keys;
    for(int i = 0; i < m; i++) {
        cin >> price >> k;
        int num = 0;
        while(k--) {
            cin >> bit;
            num = num | (1 << (bit-1));
        }
        if (keys.count(num) == 0)
            keys[num] = price;
        else
            keys[num] = min(keys[num], price);
        // printf("key = %d\n", num);
    }
    vector<int> dp(1<<n, 1e7);
    dp[0] = 0;
    for(auto p: keys) {
        for(int state = (1<<n)-1; state >= 0; state--) {
            if ((state | p.first) != state) {
                dp[state|p.first] = min(dp[state|p.first], dp[state]+p.second);
            }
        }
    }
    if (dp[(1<<n)-1] == 1e7)
        cout << -1 << endl;
    else
        cout << dp[(1<<n)-1] << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
vector<int> g[N];
int t[N];
int dfs(int u, int p, int time){
	t[u] = time;
	for(auto v:g[u])
		if(v!=p) 
			dfs(v,u,time+1);
}
int reach[N];
int dfs2(int u, int p, int time){
	if(time<t[u]) reach[u] = 1;
	// for(auto j:g[u]){
	// 	if(j!=p && t[j]>time+1)
	// 		f=0;
	// }
	// if(f) return 0;
	int ans = 0;
	for(auto j:g[u])
	if(j!=p){
		// trace(ans,u);
		ans = max(ans, 1+dfs2(j,u,time+1));
	}
	return ans;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		int u,v;
		cin >> n >> u >> v;
		rep(i,0,n-1){
			int x,y;
			cin >> x >> y;
			g[x].pb(y);
			g[y].pb(x);
		}
		dfs(v,0,0);
		// rep(i,1,n+1) cout<<t[i]<<endl;
		dfs2(u,0,0);
		int ans = 0;
		rep(i,1,n+1) ans = max(ans, reach[i]*t[i]);
		cout<<ans-1;
	}   
}     

Measured memory_bytes: 37248
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   n=n%10;
   if(n==3)
    cout<<"bon"<<endl;
   else if(n==0 || n==1 ||n== 6 || n==8)
   cout<<"pon"<<endl;
   else
   cout<<"hon"<<endl;



}


Measured memory_bytes: 3636
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M;
int A[300][300];

bool solve(int x) {
	int p[300] = {}; // 見ている箇所 -1:終了
	bool done[300] = {}; // 飛ばしたスポーツ
	bool succ[300] = {}; // okなスポーツ
	
	while (true) {
		int cnt[300] = {};
		
		REP(i, N) if (p[i] != -1) {
			while (p[i] < M && done[ A[i][p[i]] ]) p[i]++;
			if (p[i] == M) return false;
			cnt[ A[i][p[i]] ]++;
		}
		
		vector<pii> v; // 人数, スポーツid
		REP(i, M) if (cnt[i] != 0) v.push_back(pii(cnt[i], i));
		if (v.empty()) break;
		
		sort(ALL(v), greater<pii>());
		
		bool f = false;
		REP(i, v.size()) {
			if (v[i].fi > x) {
				done[v[i].se] = true;
				f = true;
			}
		}
		if (f) continue;
		
		REP(i, v.size()) {
			succ[v[i].se] = true;
			done[v[i].se] = true;
		}
		
		REP(i, N) if (p[i] != -1 && succ[ A[i][p[i]] ]) p[i] = -1;
	}
	
	REP(i, N) if (p[i] != -1) return false;
	return true;
}

int main() {
	cin >> N >> M;
	REP(i, N) REP(j, M) scanf("%d", &A[i][j]), A[i][j]--;
	
	int l = 0, r = N + 1;
	
	while (r - l > 1) {
		int m = (r + l) / 2;
		
		if (solve(m)) r = m;
		else l = m;
	}
	
	cout << r << endl;
	
	return 0;
}


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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define PRINTARR(a,b) for(int i=0;(a+i)!=(b);i++){cout << *(a+i) << " ";}PN();
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

typedef pair<int, int> PII;
typedef tuple<int, int, int> T3I;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005
int p[MAX_N];

int main()
{
    int n;
    RI(n);
    REP(i, 1, n+1) {
        RI(p[i]);
    }
    int ans = 0, i = 1;
    while(i <= n) {
        if(p[i] == i) {
            ans += 1;
            i++;
        }
        i++;
    }
    printf("%d\n", ans);
    return 0;
}


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

const char nl = '\n';

void solve()
{
    int animals, legs;
    cin >> animals >> legs;
    bool ans = false;
    if (legs % 2 == 0) {
        int twosneeded = legs / 2;
        if (twosneeded == animals) {
            ans = true;
        } else if (twosneeded > animals) {
            ans = twosneeded - animals <= animals;
        }
    }
    cout << (ans ? "Yes" : "No") << nl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

const int N = 100010;

int pres[N][2], pret[N][2];
char s[N], t[N];

int main(){
	scanf("%s%s", s + 1, t + 1);
	int lens = strlen(s + 1), lent = strlen(t + 1);
	for (int i = 1; i <= lens; ++ i){
		for (int j = 0; j < 2; ++ j){
			pres[i][j] = pres[i - 1][j];
		}
		++ pres[i][s[i] - 'A'];
	}
	for (int i = 1; i <= lent; ++ i){
		for (int j = 0; j < 2; ++ j){
			pret[i][j] = pret[i - 1][j];
		}
		++ pret[i][t[i] - 'A'];
	}
	int q;
	scanf("%d", &q);
	while (q --){
		int l1, r1, l2, r2;
		scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
		int x1 = pres[r1][0] - pres[l1 - 1][0] + (pres[r1][1] - pres[l1 - 1][1] << 1);
		int x2 = pret[r2][0] - pret[l2 - 1][0] + (pret[r2][1] - pret[l2 - 1][1] << 1);
		printf((x2 - x1) % 3 ? "NO\n" : "YES\n");
	}
	return 0;
}

Measured memory_bytes: 2304
import math
k = []
s = 0
while True:
    try:
        lst = list(map(int, input().split(',')))
        s += lst[0]*lst[1]
        k.append(lst[1])

    except EOFError:
        break

a = sum(k)/len(k)
print(s)
print(math.floor(a + 0.5))


Measured memory_bytes: 5668
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// ve<ve<要素の型>> 変数名(縦, ve<要素の型>(横, 初期値))

int main() {
  int N;
  ci(N);
  ve<st> s(N);
  rep(i, N){
    ci(s.at(i));
  }
  ve<ve<char>> t(N, ve<char> (10));
  rep(i, N){
    rep(j, 10){
      t.at(i).at(j) = s.at(i).at(j);
    }
    so(t.at(i));
  }
  so(t);
  ll c = 0, a = 0;
  rep(i, N - 1){
    if(t.at(i) == t.at(i + 1)){
      c++;
    }
    else{
      a += c * (c + 1) / 2;
      c = 0;
    }
  }
  a += c * (c + 1) / 2;
  co(a);  
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;

    int cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        if(i < 10) cnt++;
        else if(i >= 100 && i < 1000) cnt++;
        else if(i >= 10000 && i < 100000) cnt++;
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if A < B:
        if A + V * T >= B + W * T:
            ans = "YES"
        else:
            ans = "NO"
    else:
        if A - V * T <= B - W * T:
            ans = "YES"
        else:
            ans = "NO"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
O  = list(input())
E = list(input())
ans = []
size_o = len(O)
size_e = len(E)

if size_o - size_e == 0 :
    for i in range(size_o):
        ans.append(O[i])
        ans.append(E[i])
    print("{}".format("".join(ans)))
else :
    for i in range(size_e):
        ans.append(O[i])
        ans.append(E[i])
    ans.append(O[-1])
    print("{}".format("".join(ans)))

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <string>
 
int main() {
  int N, i;
  std::cin >> N;
  
  std::map<std::string, int> mp;
  std::string word;
  for (i = 0; i < N; i++) {
    std::cin >> word;
    if (mp.count(word)) {
      mp[word] += 1;
    } else {
      mp.insert(std::make_pair(word, 1));
    }
  }
  
  int max = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (max < itr->second) {
      max = itr->second;
    }
  }
  
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second == max) {
      std::cout << itr->first << std::endl;
    }
  }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
long long n, ans;
int main() {
    cin >> n; ans = n - 1;
    for(register int i = 2; i <= sqrt(n); ++i) {
        if(n % i) continue;
        ans = min(ans, n / i + i - 2);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r<0 || x+r>W){
        printf("No\n");
    }
    else if(y+r>H || y-r<0){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 584
/* Author: shriamrut
 * Language: C++17
 * Made on:26.01.2020
 * */
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
using namespace std;
void ra(auto a[],int n) { for(int i=0;i<n;i++) cin>>a[i];}
void pa(auto a[],int n) { for(int i=0;i<n;i++) cout<<a[i]<<" ";}
void rv(vector<auto>&v,int n) {v.resize(n);for(int i=0;i<n;i++)	cin>>v[i]; }
void pv(vector<auto>&v) {for(size_t i=0;i<v.size();i++) cout<<v[i]<<" ";}
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
int main() {
	IOS;
	ll n,k,ans=0;
	cin>>n>>k;
	vector<ll>a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(all(a));
	for(ll i=0;i<(n-k);i++) {
		ans+=a[i];
	}	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define BSZ  __builtin_popcount
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 1e5 + 20;
int a[N], n, idx, k;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 1) idx = i + 1;
	}
//	if (idx < k || n - idx + 1 < k)
		cout << ceil((ld)(n - 1) / (ld)(k - 1)) << endl;
//	else
//		cout << ceil((ld)(idx - 1) / (ld)(k - 1)) + ceil((ld)(n - idx) / (ld)(k - 1)) << endl;
}


Measured memory_bytes: 640
program main;
var
	n, m, i, sum : longint;
    a : array[1..10005] of longint;
begin
	sum := 0;
	readln(n,m);
	for i := 1 to m do a[i] := 0;
    for i := 1 to m do begin
    	read(a[i]);
        sum := sum + a[i];
    end;
    if sum > n 
    	then writeln(-1)
    	else writeln(n-sum);
end.

Measured memory_bytes: 1368
#include "bits/stdc++.h"

typedef long long ll;
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; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
int main() {
	int N, AB = 0, BXX = 0, XXA = 0, BXA = 0;
	cin >> N;
	string S[10000];
	for (int i = 0; i < N; i++){cin >> S[i];}

	//文字列　最初<=S<=最後 のABを数える
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < S[i].size()-1; j++)
		{
			if (S[i][j] == 'A'&&S[i][j + 1] == 'B') { AB++; }
		}
	}

	for (int i = 0; i < N; i++)
	{
		if (S[i][0] == 'B'&& S[i][S[i].size() - 1] == 'A') {BXA++;}
		else if (S[i][0] == 'B') { BXX++; }
		else if (S[i][S[i].size() - 1] == 'A') { XXA++; }
	}

	if (BXA == 0) { cout << min(XXA, BXX) + AB << endl; }
	else if (XXA + BXX == 0) { cout << BXA - 1 + XXA + AB << endl; }
	else { cout << BXA + min(XXA, BXX) + AB << endl; }
}


Measured memory_bytes: 768
"use strict"

function isSortable(args, sorted_args){
  let not_match_cnt = 0
  sorted_args.map((item, key)=>{
    if(sorted_args[key] != args[key]){
      not_match_cnt++
    }
  })
  if(not_match_cnt == 0 || not_match_cnt == 2){
    return true
  }else{
    return false
  }
}

const YES = 'YES'
const NO = 'NO'

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const args_lines = arg_str.split('\n')
const n = args_lines[0]
const target = args_lines[1].split(' ')

if(target.length != n){
  console.log(NO)
  return
}

if(Math.min(...target) != 1 || Math.max(...target) != n){
  console.log(NO)
  return
}

if(n < 2 ||  50 < n){
  console.log(NO)
  return
}

const args_asc = target.slice().sort((a,b)=>a-b)
// const args_desc = target.slice().sort((a,b)=>b-a)

const is_sortable_asc = isSortable(target, args_asc)
// const is_sortable_desc = isSortable(target, args_desc)

if(is_sortable_asc /* || is_sortable_desc */){
  console.log(YES)
}else{
  console.log(NO)
}


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

#define WHITE 0
#define GRAY 1
#define BLACK 2

static const int N = 100;
static const int FAR = (1 << 21);

int n, M[N][N];
int d[N];

void bfs(int s){
	queue<int> q; q.push(s);
	for (int i = 0; i < n; ++i) d[i] = FAR;
	d[s] = 0;

	int u;
	while (!q.empty()) {
		u = q.front(); q.pop();
		for (int v = 0; v < n; ++v) {
			if (M[u][v] == 0) continue;
			if (d[v] != FAR) continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; ++i)
		cout << i + 1 << " " << ((d[i] == FAR) ? -1 : d[i]) << endl;
}

int main(){
	cin >> n;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) M[i][j] = 0;
	}

	for (int i = 0; i < n; ++i) {
		int u, d, v; cin >> u >> d;
		for (int j = 0; j < d; ++j) {
			cin >> v;
			M[u - 1][v - 1] = 1;
		}
	}

	bfs(0);

	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 != 0) cout << "IMPOSSIBLE";
    else cout << (a + b) / 2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    
    int ans = 0;
    
    for (int i = 1; i < S.size(); i++){
        if (S[i] == S[i - 1]){
            if(S[i] == '0'){
                S[i] = '1';
            }
            else{
                S[i] = '0';
            }
            ans += 1;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable: 4244) // 最悪をします
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <sstream>
#define BIT(nr) (1UL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

//デバッグ用カッコの有無
#ifdef DEBUG
template <class T>ostream &operator<<(ostream &o, const vector<T>&v)
{
	o << "{"; for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? ", " : "") << v[i]; o << "}"; return o;
}
#endif // DEBUG

template <class T>ostream &operator<<(ostream &o, const vector<T>&v)
{
	for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? " " : "") << v[i]; return o;
}

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int dxp[4] = { 0, 1 }; // x軸方向への変位(正のみ)
int dyp[4] = { 1, 0 }; // y軸方向への変位(負のみ)

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;

	// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
	int rev;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph& g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

void solve() {

}

int dp[110][10010];

signed main() {
	int N, W;
	cin >> N >> W;
	vector<int> v(N + 1, 0), w(N + 1, 0);

	REPS(i, N) {
		cin >> v[i] >> w[i];
	}

	rep(i, 110) rep(j, 1010) {
		dp[i][j] = -LL_HALFMAX;
	}

	dp[0][0] = 0;

	REPS(i, N) {
		rep(j, W + 1) {
			if (j - w[i] >= 0) {
				chmax(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
			chmax(dp[i][j], dp[i - 1][j]);
		}
	}

	int ans = 0;
	rep(j, W + 1) {
		chmax(ans, dp[N][j]);
	}

	cout << ans << "\n";

}



Measured memory_bytes: 11032
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        System.out.println((int) Math.ceil((double) n / Math.max(h, w)));
    }

}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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 int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, W;
  cin >> N >> W;

  vector<int> w(N), v(N);
  REP(i, N) cin >> w[i] >> v[i];


  vector<vector<int>> dp(N+1, vector<int>(W+1, -INF));
  dp[0][0] = 0;

  REP(i, N) REP(j, W+1){
    chmax(dp[i+1][j], dp[i][j]);
    if(j+w[i] <= W) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
  }

  int ans = 0;
  REP(j, W+1){
    chmax(ans, dp[N][j]);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 80256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


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

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;



void solve()
{
    vector<lld> v(100001);
    cin>>n;
    lld s=0;
    for(i=0;i<n;i++)
    {
        cin>>l;
        s+=l;
        v[l]+=1;
    }
    lld q;
    cin>>q;
    for(i=0;i<q;i++)
    {
        cin>>x>>y;
        l = v[x];
        s -= l*x;
        s+=l*y;
        v[y]+=l;
        v[x]=0;
        cout<<s<<"\n";
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
     //  cout<<"\n";
    }
    return 0;
}


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

int main(){
  string s;
  cin >>s;
  
  int ans = 0;
  if(s[0]=='1') ans++;
  if(s[1]=='1') ans++;
  if(s[2]=='1') ans++;
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	-- X; -- Y;
	vector<int> res(N);
	for (int i = 0; i < N; ++ i) {
		for (int j = i+1; j < N; ++ j) {
			int d = j - i;
			d = min(d, abs(i-X)+abs(j-Y)+1);
			++ res[d];
		}
	}
	for (int i = 1; i <= N-1; ++ i) {
		cout << res[i] << endl;
	}
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());
            int ans = 0;
            while (ans * (ans + 1) / 2 < x) {
                ++ans;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"


signed main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> card(M + 10);
    for (int i = 0; i < M; i++) {
        cin >> card[i].first >> card[i].second;
        if (card[i].first > card[i].second) {
            swap(card[i].first, card[i].second);
        }
    }
    int minNumber = 0, maxNumber = N;
    for (int i = 0; i < M; i++) {
        minNumber = max(minNumber, card[i].first);
        maxNumber = min(maxNumber, card[i].second);
    }
    int ans = maxNumber - minNumber + 1;
    if (ans < 0) {
        cout << 0 << endl;
    } else cout << ans << endl;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0533

"""
import sys
from sys import stdin
input = stdin.readline

def main(args):
    W_scores = [int(input()) for _ in range(10)]
    K_scores = [int(input()) for _ in range(10)]
    W_scores.sort()
    K_scores.sort()

    W_sum = sum(W_scores[-3:])
    K_sum = sum(K_scores[-3:])
    print(W_sum, K_sum)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7700
#include <stdio.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int search(int n, int pos)
{
  if (pos >= 4) {
    return n == 0;
  } else {
    int i, c = 0;
    for (i = 0; i <= MIN(9, n); i++) {
      c += search(n - i, pos + 1);
    }
    return c;
  }
}

int main()
{
  int n;
  while (scanf("%d", &n) != EOF) {
    printf("%d\n", search(n, 0));
  }
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(void){
	int y,x,tmp = 0;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y == 0) break;
		if(x >= y){
			tmp = x;
			x = y;
			y = tmp;
		}
		printf("%d %d\n",x,y);

	}
	return 0;
}
	

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL MOD = 1000000007LL;
int main() {
	string X;
	cin >> X;
	int ans = X.size();
	int S = 0;
	for (int i = 0; i < X.size(); i++) {
		if (X[i] == 'S') {
			S++;
		}
		else {
			if (S > 0) {
				S--;
				ans -= 2;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define out(x) #x << " = " << x
#define yn(x) ((x) ? "YES" : "NO")
using namespace std;
typedef pair <int, int> ii;

const int siz = 1e4 + 10;
const int SIZ = 1e2 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;

string k;
int d;
int f[siz][2][SIZ];

int dp(int pos, int lim, int sum) {
    if (pos == sz(k)) {
        return (sum == 0);
    }

    int &res = f[pos][lim][sum];
    if (res != -1) {
        return res;
    }

    res = 0;
    int n = ((lim) ? k[pos] - '0' : 9);
    for (int i = 0; i <= n; i++) {
        (res += dp(pos + 1, lim & (i == n), (sum + i) % d)) %= mod;
    }

    return res;
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_5.INP", "r", stdin);
//    freopen ("OUT_5.OUT", "w", stdout);

    cin >> k >> d;

    memset(f, -1, sizeof(f));
    cout << (dp(0, 1, 0) - 1 + mod) % mod;

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms";

    return 0;
}


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


using namespace std;

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

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

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

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };




int main()
{
	int h, w, k;
	static char s[1024][1024];
	scanf("%d%d%d", &h, &w, &k);
	for (int i = 0; i < h; ++i)
		scanf("%s", s[i]);

	const char* joi = "JOI";
	int g = 0;
	static int sum[1024][1024][3];
	for (int y = 0; y < h; ++y)
	{
		for (int x = 0; x < w; ++x)
		{
			for (int i = 0; i < 3; ++i)
				sum[y + 1][x + 1][i] = sum[y][x + 1][i] + (sum[y + 1][x][i] - sum[y][x][i]);
			++sum[y + 1][x + 1][strchr(joi, s[y][x]) - joi];
		}
	}

	while (k--)
	{
		int y1, x1, y2, x2;
		scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
		--y1, --x1, --y2, --x2;

		int res[3];
		for (int i = 0; i < 3; ++i)
		{
			res[i] = sum[y2 + 1][x2 + 1][i] + sum[y1][x1][i]
					- (sum[y1][x2 + 1][i] + sum[y2 + 1][x1][i]);
		}

		printf("%d %d% d\n", res[0], res[1], res[2]);
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h> 
using namespace std;
 
int main(){
  int N;
  int count=0;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for(int i=0;i<N;i++){
    if(i%2==0 && vec.at(i)%2==1){
      count++;
    }
  }
  cout<<count<<endl;
  
  
}

Measured memory_bytes: 3628
arr = input().split()

a = int(arr[0])
b = int(arr[1])

c = int(arr[2])
d = int(arr[3])

tmp = []
tmp.append(a*c)
tmp.append(a*d)
tmp.append(b*c)
tmp.append(b*d)

ans = max(tmp)

print(ans)

Measured memory_bytes: 9084
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s1,s2,s3;
	char x = 'a' - 'A';
	cin >> s1 >> s2 >>s3;
	cout << char(s1[0] - x) << char(s2[0] - x) << char(s3[0] - x) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MOD (1000000007)
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

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

  bool ng = false;
  int c[n];
  c[0] = 1;
  if(a[0] < t[0]) ng = true;
  for(int i = 1; i < n; i++){
    if(t[i - 1] < t[i]){
      if(a[i] < t[i]) ng = true;
      c[i] = 1;
    }
    else c[i] = t[i];
  }
  c[n - 1] = 1;
  if(a[n - 1] > t[n - 1]) ng = true;
  for(int i = n - 2; i >= 0; i--){
    if(a[i] > a[i + 1]){
      if(a[i] > t[i]) ng = true;
      c[i] = 1;
    }
    else c[i] = min(c[i], a[i]);
  }

  ll sum = 1;
  for(int i = 0; i < n; i++){
    sum = (sum * c[i]) % MOD;
  }

  if(!ng) cout << sum << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

template <typename T> vector<T> dibs(size_t n) {
    vector<T> ans;
    ans.reserve(n);
    return ans;
}

template <typename T>
using iit = istream_iterator<T>;

int solve(vector<int>& a, int x) {
    int cst = 0;
    for (auto y : a)
        cst += (y - x) * (y - x);
    return cst;
}

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

    int n;
    cin >> n;
    auto a(dibs<int>(n));
    copy_n(iit<int>(cin), n, back_inserter(a));

    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += a[i];
    double mean = double(sum)/double(n);
    auto ans = min<int>(solve(a, floor(mean)), solve(a, ceil(mean)));
    cout << ans << '\n';
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

in_strings = lambda: stdin.readline()[:-1] # s = in_strings()
in_int = lambda: int(stdin.readline()) # N = in_int()
in_intlist = lambda: list(map(int, stdin.readline().split())) # List = in_intlist()

N = in_int()

def OrderSum(x):
    res = 0
    while (x//10) > 0:
        res += x % 10
        x = x // 10
    res += x % 10
    return res

ans = 10**3
for i in range(1, N//2 + 1):
    temp = OrderSum(i) + OrderSum(N-i)
    if ans > temp:
        ans = temp
print(ans)


Measured memory_bytes: 3064
i = list(map(int, input().split()))
numBook  = i[0]
numTopic = i[1]
minKnow = i[2]
i=0
j=0 

Mat = [list(map(int, input().split()))  for i in range(numBook)]
#print(Mat)

#可能判定
for i in range(1,numTopic+1)	:
	knowledge = 0
	cost_out = 0
	for j in range(0,numBook)	:
		knowledge += Mat[j][i] 
		cost_out += Mat[j][0]
	if knowledge < minKnow	:
		print("-1")
		exit()	

#print("max cost is ",cost_out)
#価格策定
#print(2**numBook,"pattern")
for i in range(0,2**numBook)  :
	bin_str = format(i, '012b')
#	print("challenge with ",bin_str)
	#print(bin_str,"=>",bin_str[11])
	for i in range(1,numTopic+1)	:
		knowledge = 0
		cost = 0
		for j in range(0,numBook)	:
			knowledge += Mat[j][i] *int(bin_str[11-j])
			cost += Mat[j][0] * int(bin_str[11-j])
#		print("for topic", i, "this challenge gave knowledge of ", knowledge)
		if knowledge < minKnow	:
#			print("which is not enough.")
			break
	#print("this time it got ",cost)
	if cost != 0 	:
		if j == numBook-1 :
			if knowledge >= minKnow	:
				if cost < cost_out:
					cost_out = cost
					#print("with", bin_str)
print(cost_out)

Measured memory_bytes: 9272
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N; cin>>N;
  string S; cin>>S;

  int ans=0;
  rep(i,N-1){
    bool ch1[26]={};
    bool ch2[26]={};
    rep(j,N){
      if(j<=i) ch1[S[j]-'a']=true;
      else ch2[S[j]-'a']=true;
    }
    int temp=0;
    rep(i,26){
      temp+=(ch1[i] and ch2[i]);
    }
    maxi(ans,temp);
  }

  cout<< ans<<"\n";

}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<string, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}



int main()
{
	int n;
	cin >> n;
	vector<pair<string, int>>res(n);
	map<int, int>num;
	rep(i, n) {
		cin >> res[i].F >> res[i].second;
		res[i].second *= -1;
		num[res[i].S] = i + 1;
	}

	sort(all(res));


	rep(i, n) {
		cout << num[res[i].S] << endl;
	}
}



Measured memory_bytes: 256