akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
void check(const vector<string> &A) {
    int H = A.size(), W = A[0].size();
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] != A[H-1-i][W-1-j]) {
                return;
            }
        }
    }
    cout << "YES\n";
    exit(0);
}
bool revequal(const string &s, const string &t) {
    if (s.size() != t.size()) return false;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[s.size() - 1 - i]) return false;
    }
    return true;
}
int main() {
    int H, W; cin >> H >> W;
    vector<string> A(H); for (auto &a : A) cin >> a;
    map<string, vector<int>> M;
    for (int i = 0; i < H; i++) {
        string s = A[i];
        sort(begin(s), end(s));
        M[s].push_back(i);
    }
    vector<pair<string, vector<int>>> rows(begin(M), end(M));
    vector<string> B(H);
    auto column = [&]() {
        vector<string> C(W), D(W);
        for (int i = 0; i < W; i++) {
            string s;
            for (int j = 0; j < H; j++) s.push_back(B[j][i]);
            C[i] = s;
        }
        vector<int> done(W);
        int cnt = 0;
        for (int i = 0; i < W; i++) {
            for (int j = i + 1; j < W; j++) {
                if (done[i] || done[j]) continue;
                if (revequal(C[i], C[j])) {
                    D[cnt] = C[i];
                    D[W-1-cnt] = C[j];
                    cnt++;
                    done[i] = done[j] = 1;
                }
            }
        }
        for (int i = 0; i < W; i++) {
            if (!done[i]) {
                D[cnt] = C[i];
                done[i] = 1;
                break;
            }
        }
        if (accumulate(begin(done), end(done), 0) == W) {
            check(D);
        }
    };
    auto recur = [&](auto& recur, int idx, int t, int center) -> void {
        if (idx >= rows.size()) { column(); return; }
        auto& p = rows[idx];
        int flag = p.second.size() % 2;
        if (flag && center) return;
        center = flag;
        vector<bool> used(p.second.size());
        auto recur2 = [&](auto& recur2) -> void {
            int i = 0;
            while (i < p.second.size() && used[i]) i++;
            if (i == p.second.size()) {
                recur(recur, idx + 1, t, center);
                return;
            }
            used[i] = 1, B[t] = A[p.second[i]];
            for (int j = i + 1; j < p.second.size(); j++) if (!used[j]) {
                used[j] = 1, B[H-1-t] = A[p.second[j]];
                t++;
                recur2(recur2);
                t--;
                used[j] = 0;
            }
            used[i] = 0;
        };
        for (int i = 0; i < (flag ? p.second.size() : 1); i++) {
            if (flag) used[i] = 1, B[H / 2] = A[p.second[i]];
            recur2(recur2);
        }
    };
    recur(recur, 0, 0, 0);
    cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> T1 pow_(T1 a, T2 b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  ll a, b, n;
  cin >> a >> b >> n;
  auto f = [&](ll x) {
    return a * x / b - a * (x / b);
  };
  if (n >= b) {
    n = b - 1;
  }
  cout << f(n) << endl;
}


Measured memory_bytes: 3692
import sys
import math
input = sys.stdin.readline

N=int(input())

arr=list(map(int,input().split()))

ans=[0]*N

ans[N-2]=abs(arr[-2]-arr[-1])

for i in range(N-3,-1,-1):
	ans[i] = min(abs(arr[i]-arr[i+1])+ans[i+1],abs(arr[i]-arr[i+2])+ans[i+2])

print(ans[0])

Measured memory_bytes: 14104
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,a[505][505],b[505],Ans,Mn,sum;
char nc()
{
	char c=getchar();
	while(c!='#'&&c!='.') c=getchar();
	return c;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)b[i]=1;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
		a[i][j]=(nc()=='#'),b[j]&=a[i][j],sum+=a[i][j];
	if (!sum) return puts("-1"),0;
	for (int i=1;i<=n;i++)
		if (!b[i]) Ans++;
	Mn=100000000;
	for (int i=1;i<=n;i++)
	{
		int t=0,now=0;
		for (int j=1;j<=n;j++)
			if (a[j][i]) {t=j;break;}
		if (t==0) now++;
		for (int j=1;j<=n;j++)
			if (!a[i][j]) now++;
		Mn=min(Mn,now);
	}
	if (Mn==100000000)
		puts("-1");
	else printf("%d\n",Mn+Ans);
	
}

Measured memory_bytes: 1280
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
 
####
from collections import deque
def solve(N, M):
    ans = []
    if N & 1:
        tops = deque(xrange(1, 2 * M + 1))
        while tops:
            ans.append([tops.popleft(), tops.pop()])
 
    else:
        # 1, 2, 3, 4, ..., M
        # there are (M+1)/2 odd numbers
        odds = (M + 1) // 2
        evens = M - odds
        i = odds
        d = 1
        for m in range(1, odds + 1):
            ans.append([i, i+d])
            i -= 1
            d += 2
        i = 2 * odds + evens
        d = 2
        for m in range(1, evens + 1):
            ans.append([i, i+d])
            i -= 1
            d += 2
            
 
    for row in ans:
        print "{} {}".format(*row)

solve(*rrm())


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const int MOD = 998244353;

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

	int n, k; cin >> n >> k;
	vi v(n); FOR(i, n) cin >> v[i];

	sort(all(v));

	ll ans = 0;
	FOR(i, k)
		ans += v[i];

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3648
def main():
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy
    print('U' * dy + 'R' * dx, end='')
    print('D' * dy + 'L' * dx, end='')
    print('L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D', end='')
    print('R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U')


if __name__ == '__main__':
    main()


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N, M;

  while(cin >> N >> M){
    vector<pair<int,int>> temp;

    if(M % 2 == 1){
      FORE(i,1,M/2+1){
        temp.emplace_back(i, i + M - 2 * (i - 1));
      }

      FORE(i,1,M/2){
        int j = i + M + 1;
        temp.emplace_back(j, j + M - 2 * (i - 1) - 1);
      }
      
    }else{
      FORE(i,1,M/2){
        temp.emplace_back(i, i + M - 2 * (i - 1) - 1);
      }

      FORE(i,1,M/2){
        int j = i + M;
        temp.emplace_back(j, j + M - 2 * (i - 1));
      }
      
    }

    dump(temp);

    vector<pair<int,int>> ans(temp.begin(), temp.begin() + M);
    
    for(auto [a, b] : ans){
      pout(a, b);
    }
  }

  return 0;
}


Measured memory_bytes: 4568
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int n,m,count,ans=0;
	cin >> n;
	vector<string> s(n);
	for(int i=0; i<n; i++)cin >> s[i];
	cin >> m;
	vector<string> t(m);
	for(int i=0; i<m; i++)cin >> t[i];
	for(int i=0; i<n; i++){
		count=0;
		for(int j=0; j<n; j++)if(s[i]==s[j])count++;
		for(int j=0; j<m; j++)if(s[i]==t[j])count--;
		ans=max(ans,count);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

S = input()


def is_palindrome(s):
    N = len(s)
    if N == 1:
        return True

    half = N // 2
    f = s[:half]
    r = s[-half:][::-1]
    return f == r


if is_palindrome(S) and is_palindrome(S[: len(S) // 2]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int cnt[111];

int main(){
  int N,K; cin>>N>>K;
  rep(i,K){
    int D; cin>>D;
    rep(j,D){
      int A; cin>>A; A--;
      cnt[A]++;
    }
  }
  int ans=0;
  rep(i,N) ans+=(cnt[i]==0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    N,M = map(int,input().split())
    key = []
    for _ in range(M):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        can_open = 0
        for i in c:
            can_open ^= 1<<(i - 1)
        key.append((a,can_open))
    
    dp = [[INF] * (1<<N) for _ in range(M + 1)]
    for i in range(M):
        dp[i][0] = 0
    
    for i in range(M):
        price,can_open = key[i]
        for s in range(1,1<<N):
            dp[i + 1][s] = min(dp[i][s],dp[i][(s&can_open)^s] + price)
    print(dp[-1][-1] if dp[-1][-1] != INF else -1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35924
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int a,b,n;
	int x,y;
	int dp[17][17];
	
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
		for(int i=0;i<17;i++) fill_n(dp[i],17,0);
		dp[1][1]=1;
		
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			dp[x][y]=-1;
		}
		for(int i=1;i<=a;i++){
			for(int j=1;j<=b;j++){
				if(dp[i][j]!=-1){
					if(dp[i][j-1]!=-1) dp[i][j]+=dp[i][j-1];
					if(dp[i-1][j]!=-1) dp[i][j]+=dp[i-1][j];
				}
			}
		}
		printf("%d\n",dp[a][b]);
	}
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,ans;
    int cnt_m=-1;
    cin >> n;
    for(int i=1; i<=n; i++){
        int cnt=0;
        int f = i;
       while(f % 2 == 0){
           f /= 2;
           cnt ++;
       }
        if(cnt>cnt_m){
            cnt_m = cnt;
            ans = i;
        }
        }
        cout << ans << endl;
    }

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMinimum(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMaximum(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {

    int H1,H2, M2,M1,K;


    cin >> H1 >> M1 >> H2 >> M2 >>K;


    int ans;
    int h = H1*60 +M1;
    int hh = H2*60 + M2;

    ans = hh-h-K;



    cout << ans << endl;
}

Measured memory_bytes: 3636
//int型は32bit整数なのでそれを超える範囲では表現できない
//32bit整数→2^31であり、2^10は大体10^3なので2*10^9までしか表すことができない
//long longは64bit整数であり、2^63まで表すことができる

#include<iostream>
#include<vector>
using namespace std;

int tax(int p,int n){
  return int(n*(100+p)/100);
}

int tax_count(int x,int y,int s){
  int maximum=0;
  for(int i=1;i<s;i++)
    for(int j=i;j<s;j++)
      if(tax(x,i)+tax(x,j)==s)
        maximum=max(maximum,tax(y,i)+tax(y,j));
  return maximum;
}

int main(){
  int X,Y,S;
  vector<int> a;
  while(cin>>X>>Y>>S && X>0){
    a.push_back(tax_count(X,Y,S));
  }
  for(int i=0;i<a.size();i++)
    cout<<a[i]<<endl;
}



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

int main(void){
    int a,b,ans;
    cin >> a;
    cin >> b;
    if(a >= b){
        ans = a;
        a--;
    }else{
        ans = b;
        b--;
    }
    if(a >= b){
        ans += a;
    }else{
        ans += b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lld;
 
#define forn(i,n) for(ll i = 0;i<n;i++)
#define forne(i,j,n) for(ll i = j;i<n;i++)
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ll INF = 3e18;
const ll N = 100001;
const lld PI = 3.141593;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n,fa = 0;
cin>>n;
ll a[n];
set<ll> s;
forn(i,n) cin>>a[i];
map<ll,ll> m;
forn(i,n){
	m[a[i]]++;
	s.insert(a[i]);
}
set<pair<ll,pll>> ss;
for(auto i:s){
	for(auto j:s){
		for(auto k:s){
			if(i == j || j == k || k == i) continue;
			else{
				ll b[3];
				b[0] = i;
				b[1] = j;
				b[2] = k;
				sort(b,b+3);
				// cout<<b[0]<<" "<<b[1]<<" "<<b[2]<<endl;
				if(b[0] + b[1] > b[2]) ss.insert({b[0],{b[1],b[2]}});
			}
		}
	}
}
for(auto i:ss){
	fa+=(m[i.F]*m[i.S.F]*m[i.S.S]);
}
cout<<fa<<endl;
}

Measured memory_bytes: 13584
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define vi vector<int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, a, b;
	cin>>n>>a>>b;
	if((b - a) % 2 == 0){
		cout<<(b - a) / 2<<endl;
	}
	else{
		ll ans = min(n - a, b - 1);
		ans = min(ans, (a - 1) + 1 + (b - ((a - 1) + 1)) / 2);
		ans = min(ans, (n - b) + 1 + (n - (a + (n - b) + 1)) / 2);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  if((a+2)>=b){
    cout << k+1 << endl;
    return 0;
  }
  
  else {
    ll ans=max(k+1, a+(k-(a-1))/2*(b-a)+((k-(a-1))%2)*1);
    cout << ans << endl;
    return 0;
  }
  
}

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

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL A, B, K;
	cin >> A >> B >> K;

	if(A+B <= K){
		printf("0 0\n");
		return 0;
	}

	LL d = max(0LL, A - K);
	if(d > 0){
		printf("%lld %lld\n", d, B);
	}
	else{
		printf("%lld %lld\n", 0LL, B - (K - A));
	}
	return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<set>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	set <string> S;
	int n=s.size();
	for(int i=1;i<=min(n,5);i++)
		for(int j=0;j<s.size()-i+1;j++)
			S.insert(s.substr(j,i));
	set <string>::iterator it=S.begin();
	int k;
	cin>>k;
	k--;
	while(k--)it++;
	cout<<*it<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int a[10005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n,cnt=0;
	cin >> n;
	for(int i=1;i<=150;i++){
		for(int j=1;j<=150;j++){
			for(int k=1;k<=150;k++){
				int x = (i+j)*(i+j)+(k+j)*(k+j)+(i+k)*(i+k);
				if(!(x&1)&&x/2<=10000) a[x/2]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}


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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(all(a));
    cout<<a[n-1]-a[0]<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

"""
import sys


def solve(targets, stars):
    for tx, ty in targets:
        for sx, sy in stars:
            dx, dy = sx-tx, sy-ty
            s_starts = set(stars)
            for x, y in targets:
                px, py = x+dx, y+dy
                if (px, py) in s_starts:
                    s_starts.remove((px, py))
                else:
                    break
            else:
                return dx, dy


def main(args):
    while True:
        m = int(input())
        if m == 0:
            break
        targets = [tuple(int(x) for x in input().split()) for _ in range(m)]
        n = int(input())
        stars = [tuple(int(x) for x in input().split()) for _ in range(n)]
        ans = solve(targets, stars)
        print(*ans)


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



Measured memory_bytes: 6080
#include<iostream>
#include<queue>
using namespace std;
typedef unsigned long long ull;
int main(){
		int k;
		cin >> k;
		ull x;
		queue<ull> q;
		q.push(1);q.push(2);q.push(3);q.push(4);q.push(5);q.push(6);q.push(7);q.push(8);q.push(9);
		//cout << q.front() << endl;
		while(k--){
			x = q.front();
			q.pop();
			if(x%10!=0) q.push(10*x + x%10 - 1);
			q.push(10*x + x%10);
			if(x%10!=9) q.push(10*x + x%10 + 1);
		}
		cout << x << endl;
	
}


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


#define INF 1000000000000


signed main()
 {
   int n,m;
   cin>>m>>n;
   int nissuu=0;
   rep(i,n){
     int k;
     cin>>k;
     nissuu+=k;
   }
   if(m>=nissuu){
cout<<m-nissuu;
}
else cout<<"-1";
 }


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector <char> v;
vector<int> num;

int main(){
  int A,B;
  int ans = 0;

  cin >> A>>B;

  for (int i = A; i < B+1; i ++ ){
    string s = to_string(i);
    if(s[0] == s[4]&&s[1] == s[3])
    ans++;
  }

  cout <<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <stdexcept>
#include <vector>
using namespace std;


#define abs(N) ((N>0)?N:-1*N)
#define lt(A,B) ((A>B)?B:A)
#define gt(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)
#define ll long long int

int BinarySearch(ll * S, int n, ll key){
//	println("=============================");
	int l=n-1,r=0,c;
	while(true){
		c = (r-l)/2+l;
		if(l == c || r == c) break;
//		printf("S[%d](=%lld) - S[%d](=%lld) - S[%d](=%lld)\n",r,S[r],c,S[c],l,S[l]);
		if(key < S[c]){
			l = c;
		}else if(S[c] < key){
			r = c;
		}else{
			return c;
		}
	}
//	printf("S[%d](=%lld) - S[%d](=%lld)\n",r,S[r],l,S[l]);
	if(S[r] == key) return r;
	if(S[l] == key) return l;

	return -1;
}

int main(){
	int n,q;
	cin >> n;
	ll S[n+1];
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
	}
	cin >> q;
	int cnt=0;
	for (int i = 0; i < q; ++i) {
		ll Q;
		cin >> Q;
		if(BinarySearch(S,n,Q)!=-1) cnt++;
	}
	println(cnt);

	return 0;
}




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

using namespace std;

int main(){
	int a[5];
	int index,mn=10;
	for(int i = 0;i < 5;i++){
		cin >> a[i];
		if(a[i]%10 != 0 && mn > a[i]%10){
			mn = a[i]%10;
			index = i;
		}
	}
	
	int ans = 0;
	for(int i = 0;i < 5;i++){
		if(i != index){
			if(a[i]%10 == 0){
				ans += a[i];
			}else{
				ans += a[i] - a[i]%10 + 10;
			}
		}else{
			ans += a[index];
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

//Eratosthenes O(N)
vector<int> Eratosthenes(int N) {
    vector<int> res(N + 1, 1);
    res[0] = res[1%(N+1)] = 0;
    for (int i = 1; i*i <= N; i++) if (res[i]) for (int j = 2 * i; j <= N; j += i) res[j] = 0;
    return res;
}

//verify https://atcoder.jp/contests/abc084/tasks/abc084_d

int main() {
	int X; cin >> X;
	auto p = Eratosthenes(X + 100000);
	for(int i = X; ; i++){
		if(p[i]){
			cout << i << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 1024
fn main() {
    let n = read::<u64>();
    let mut i = 1;
    while i * i <= n {
        i += 1;
    }
    i -= 1;
    println!("{}", i * i);
}

#[allow(dead_code)]
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()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define Fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long

int32_t main() {
	Fast_IO

	string s; cin >> s;
	string t; cin >> t;
	if (t.substr(0, s.size()) == s and t.size() == s.size() + 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

Measured memory_bytes: 3652
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def f(N):
    return (math.ceil(N / 10)) * 10


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    ABCDE = itertools.permutations([ii() for _ in range(5)])

    ret = MAX
    for a, b, c, d, e in ABCDE:
        ret = min(ret, f(a) + f(b) + f(c) + f(d) + e)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>

int main(){
 int h, m, s;
 std::cin >> s;
 
 h = s/3600;
 s %= 3600;
 m = s/60;
 s %= 60;

 std::cout << h << ":" << m << ":" << s << "\n";

 return 0;
}
 

Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N, M;
	string S;
	cin >> N >> M >> S;

	vector<ll> vec;

	ll pos = N;
	while (1) {

		ll next = max(0LL, pos - M);

		rep(i, M) {
			if (S[next] == '1') next++;
			else break;
		}

		if (next == pos) {
			cout << "-1";
			return;
		}
		else {
			vec.emplace_back(pos - next);
		}

		pos = next;
		if (pos == 0) break;
	}

	debug(vec);

	rep(i, vec.size()) {
		cout << vec[vec.size() - 1 - i] << " ";
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


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

def f():
    lb = 0
    ub = N - 1
    
    print(lb, flush=True)
    lba = input()
    if lba == 'Vacant': return
    
    print(ub, flush=True)
    uba = input()
    if uba == 'Vacant': return
    
    while lb < ub:
        qry = (lb + ub) // 2
        print(qry, flush=True)
        qa = input()
        if qa == 'Vacant': return
        if (not ((lb ^ qry) & 1) and lba == qa) or (((lb ^ qry) & 1) and lba != qa):
            lb = qry
            lba = qa
        else:
            ub = qry

f()

Measured memory_bytes: 3660
#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 <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main()
{
    int n;
    cin >> n;
    vector<string> a;
    string l;
    int flag = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> l;
        if (i != 0)
        {
            if (std::find(a.begin(), a.end(), l) != a.end())
            {
                flag = 1;
            }
            else
            {
                if (l[0] != a[a.size() - 1][a[a.size() - 1].length() - 1])
                {
                    flag = 1;
                }
            }
        }
        a.pb(l);
    }
    if (flag == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
    cout << "hon"<< endl;
  if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
    cout << "pon"<< endl;
  if(n % 10 == 3)
    cout << "bon"<< endl;
  return 0;
}
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

 
int main(){
  int n,m;
  cin >> n >> m;
  if(n>m){n--;}
  cout << n << endl;
  return 0;
}


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

using namespace std;

int main(){
    int N;
    int count = 0;
    string S;
    cin >> N >> S;
    for(int i=0; i<N-2;i++){
        if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
import sys
sys.setrecursionlimit(10 ** 6)
h=list(map(int,input().split()))
cos={0:0,1:abs(h[1]-h[0])}
def cost(x):
  if x not in cos:
    d1=cost(x-1)+abs(h[x]-h[x-1])
    d2=cost(x-2)+abs(h[x]-h[x-2])
    cos[x]=min(d1,d2)
    return cos[x]
  else:
    return cos[x]
  
print(cost(n-1))

Measured memory_bytes: 102796
use v6;
my $n = get().chomp;
my $str1 = get().chomp;
my $str2 = get().chomp;
my $ans = $n * 2;
loop (my $i = 0; $i < $n; $i++) {
	my $s1 = $str1.substr($i);
	my $s2 = $str2.substr(0, $n - $i);
	if $s1 eq $s2 {
		$ans = $n + $i;
		last;
	}
}
say $ans;

exit;

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

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;

    string t("keyence");

    if (s.size() < t.size()) {
        cout << "NO" << endl;
    } else if (s.find(t) == 0 || s.rfind(t) == (s.size() - t.size())) {
        cout << "YES" << endl;
    } else {
        bool yes(false);
        for (int i = 0; i < t.size(); i++) {
            string one = t.substr(0, i + 1);
            string other = t.substr(i + 1);

            int one_pos = s.find(one);
            int other_pos = s.rfind(other);
            if (one_pos == 0 && other_pos == s.size() - other.size()) {
                yes = true;
                break;
            }
        }
        cout << ((yes) ? "YES" : "NO") << endl;
    }
    
	return 0;
}


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

int main(void){
	
	int n; scanf("%d", &n);
	std::vector<std::pair<int, int>> edges;
	
	int fulln = n - n%2;
	for(int i=1; i<=fulln; i++){
		for(int j=i+1; j<=fulln; j++){
			if(i+j != fulln+1) edges.push_back({i, j});
		}
	}
	if(n%2 == 1){
		for(int i=1; i<=fulln; i++) edges.push_back({i, n});
	}
	printf("%d\n", edges.size());
	for(auto edge: edges) printf("%d %d\n", edge.first, edge.second);
	
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(ll i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(arg),key)-begin(arg)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))

using namespace std;

using R=long double;
const R EPS = 1E-11;
const R INF = 1E40;
constexpr R PI = acos(R(-1));
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}

using P=complex<R>;

constexpr P O = P(0,0);

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

//?????? dot ?????? det
inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}

using L=struct{P s,t;};

// ?°???± verify AOJ CGL_1_A
P proj(P o,P a,P b){ a-=o,b-=o; return a*real(b/a);}
P proj(L l,P p){ return l.s+proj(l.s,l.t,p);}
// ????°? verify AOJ CGL_1_B
P refl(L l,P p){ return R(2.0)*proj(l,p)-p;}
// CCW verify AOJ CGL_1_C
enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a, P b) {//???a??¨???b???????????????????????????
	if (sgn(det(o,a,b)) > 0) return LEFT;    // counter clockwise
	if (sgn(det(o,a,b)) < 0) return RIGHT;   // clockwise
	if (sgn(dot(o,a,b)) < 0) return BACK;    // b--base--a on line
	if (sgn(norm(a)-norm(b)) < 0) return FRONT;   // base--a--b on line
	return ON;// base--b--a on line  a??¨b????????????????????????
}

int main(void){
	P a,b,p;
	int n;
	cin >> a >> b >> n;
	L l={a,b};
	cout.precision(20);
	rep(i,n){
		cin >> p;
		P ans=refl(l,p);
		cout << fixed << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3284
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        conversionChar(str);
    }
    
    static void conversionChar(String str){
        List<String> charList = new ArrayList<String>();
        for(int i = 0; i<str.length(); i++){
            charList.add(str.substring(i,i+1));
            if(Character.isUpperCase(str.charAt(i))){
                charList.set(i, str.substring(i,i+1).toLowerCase());
            }else if(!Character.isUpperCase(str.charAt(i))){
                charList.set(i, str.substring(i,i+1).toUpperCase());
            }
        }
        for(String resultChar : charList){
            System.out.print(resultChar);
        }
        System.out.println("");
    }
}


Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}
bool flag[200010];
int b[200010];
int f[200010];
int tof[200020];
int tob[200020];
int res1[200010];
int res2[200010];
int N, K, C;
string S;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K >> C >> S;
    tof[0] = N;
    tob[N - 1] = N;
    if(C == 0){
        vector<int> vs;
        for(int i = 0; i < N; i++){
            if(S[i] == 'o') vs.push_back(i);
        }
        if(vs.size() == K){
            for(auto u : vs) cout << u + 1 << endl;
        }
        return 0;
    }
    for(int i = 0; i < N; i++){
        if(i != 0) tof[i] = tof[i - 1];
        if(S[i] == 'o') tof[i] = i;
    }
    for(int i = 0; i < N; i++){
        if(i != 0) f[i] = f[i - 1];
        if(S[i] == 'o'){
            if(i - C - 1 >= 0) chmax(f[i], f[tof[i - C - 1]] + 1);
            else chmax(f[i], 1);
        }
    }
    for(int i = N - 1; i > 0; i--){
        tob[i] = tob[i + 1];
        if(S[i] == 'o') tob[i] = i;
    }
    for(int i = N - 1; i >= 0; i--){
        b[i] = b[i + 1];
        if(S[i] == 'o'){
            if(i + C + 1 < N) chmax(b[i], b[tob[i + C + 1]] + 1);
            else chmax(b[i], 1);
        }
    }
    for(int i = 0; i < N; i++){
        res1[i] = f[i];
        if(i + C + 1 < N) res1[i] += b[i + C + 1];
    }
    for(int i = N - 1; i >= 0; i--){
        res2[i] = b[i];
        if(i  - C - 1 >= 0) res2[i] += f[i - C - 1];
    }

    int ov = 0;
    for(int i = 1; i <= C; i++){
        if(res2[i] >= K) ov++;
    }
    for(int i = 0; i < N; i++){
        if(S[i] == 'o'){
            if(ov == 0) cout << i + 1 << endl;
        }
        if(i - C >= 0){
            if(res1[i - C] >= K) ov--;
        }
        if(i + C + 1 < N){
            if(res2[i + C + 1] >= K) ov++;
        }
        if(res2[i + 1] >= K) ov--;
        if(res1[i] >= K) ov++;
    }
    return 0;
}

Measured memory_bytes: 5268
#include<stdio.h>

int main()
{
	int a,b,arr[9],r,i,j;
	scanf("%d %d",&a,&b);

	arr[1]=a+b;
	arr[2]=a-b;
	arr[3]=a*b;

	for(i=1;i<=3;i++)
    {
        for(j=i;j<=3;j++)
        {
            if(arr[j]>=arr[i])
            {
                r=arr[i];
                arr[i]=arr[j];
                arr[j]=r;
            }
        }
    }

    printf("%d",arr[1]);

    return 0;

}


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

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x = i;
        if (x % 3 == 0)
        {
            cout << " " << i;
            continue;
        }

        while (x)
        {
            if (x % 10 == 3)
            {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}



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


def solve(data):
    increasing = True
    prev_line = data[0]
    for curr_line in data[1:]:
        if len(curr_line) < len(prev_line):
            increasing = False
        for i, ele in enumerate(curr_line):
            if increasing:
                if i == 0:
                    curr_line[0] += prev_line[0]
                else:
                    try:
                        up_right = prev_line[i]
                    except:
                        up_right = 0
                    curr_line[i] += max(prev_line[i-1], up_right)
            else:
                    curr_line[i] += max(prev_line[i], prev_line[i+1])
        prev_line = curr_line
    return data[-1][0]


def main(args):
    data = []
#    data.append([7])
#    data.append([3,8])
#    data.append([8,1,0])
#    data.append([2,7,4,4])
#    data.append([4,5,2,6,5])
#    data.append([2,7,4,4])
#    data.append([8,1,0])
#    data.append([3,8])
#    data.append([7])

    for line in sys.stdin:
        data.append([int(x) for x in line.split(',')])
    result = solve(data)
    print(result)



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

Measured memory_bytes: 7680
n = int(input())
s = input()

color_length = []
c = 1

for i in range(n-1):
    
    if s[i] == s[i+1]:
        c += 1
    
    else:
        color_length.append(c)
        c = 1

color_length.append(c)

print(len(color_length))



Measured memory_bytes: 3956
#include<iostream>
#include <list>

using namespace std;

int main(int argc, char const *argv[]) {
  unsigned int n, tmp;
  list<int> lst;
  cin >> n;

  for(int i=0; i<n; i++){
    cin >> tmp;
    lst.push_back(tmp);
  }

  lst.sort();
  tmp = 0;

  for(int i=0; i<n; i++){
    if(i%2)
      tmp -= *(--lst.end());
    else
      tmp += *(--lst.end());
    lst.pop_back();
  }

  cout << tmp;

  return 0;
}


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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<int,string> pis;

int solve(string s)
{
	set<string> memo;
	priority_queue<pis,vector<pis>,greater<pis> > pq;
	pq.push(mp(0,s));
	while(!pq.empty()){
		pis cur=pq.top(); pq.pop();
		int curf=cur.first;
		string curs=cur.second;
		if(count(allof(curs),curs[0])==curs.size())
			return curf;
		if(memo.find(curs)!=memo.end())
			continue;
		memo.insert(curs);
		
		rep(i,curs.size()-1){
			char a=curs[i],b=curs[i+1];
			if(a==b)
				continue;
			if(a=='r' && b=='g' || a=='g' && b=='r') curs[i]=curs[i+1]='b';
			if(a=='g' && b=='b' || a=='b' && b=='g') curs[i]=curs[i+1]='r';
			if(a=='b' && b=='r' || a=='r' && b=='b') curs[i]=curs[i+1]='g';
			pq.push(mp(curf+1,curs));
			curs[i]=a;
			curs[i+1]=b;
		}
	}
	return -1;
}

int main()
{
	for(string s;cin>>s,s[0]!='0';){
		int res=solve(s);
		if(res==-1)
			puts("NA");
		else
			cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2164