akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    lint s[N];
    cins(s, s + N);
    N--;
    lint ans = 0;
    for(int diff = 1; diff <= N; diff++){
        lint sum = 0;
        for(int i = 0; i < N - diff; i += diff){
            sum += s[i] + s[N - i];
            int move = i / diff;
            if(N % diff == 0 && N / diff <= move * 2){
                continue;
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n, m, x, dp[100010];
bool vis[15];
const int ms[10]= {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i){
		scanf("%d", &x);
		vis[x] = 1;
	}
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	for(int i = 1; i <= 9; ++i){
		if(!vis[i]) continue;
		for(int j = ms[i]; j <= n; ++j){
			dp[j] = max(dp[j], dp[j - ms[i]] + 1);
		}
	}
	int res = n;
	while(res){
		for(int i = 9; i >= 1; --i){
			if(vis[i] && res >= ms[i] && dp[res] == dp[res - ms[i]] + 1){
				printf("%d", i);
				res -= ms[i];
				break;
			}
		}
	}
	return 0;
}
//c___s AK IOI

Measured memory_bytes: 768
import java.util.Scanner;
import java.util.LinkedList;

public class Main {
    public static Scanner sc;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);
        char[][] ary;

        while (sc.hasNext()) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            
            if (h == 0 && w == 0) break;
            
            ary = new char[h][w];
            
            for (int i = 0; i < h; i++) {
                String s = sc.next();
                for (int j = 0; j < w; j++) {
                    ary[i][j] = s.charAt(j);
                }
            }
            
            // ?????¨??????
            int x = 0;
            int y = 0;
            
            while (true) {
                char c = ary[x][y];
                ary[x][y] = 'L';
                
                if (c == '>') {
                    y++;
                } else if (c == '<') {
                    y--;
                } else if (c == 'v') {
                    x++;
                } else if (c == '^') {
                    x--;
                } else if (c == '.') {
                    System.out.println(y + " " + x);
                    break;
                } else if (c == 'L') {
                    System.out.println("LOOP");
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 29216
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
        double timeTaken = (double)d / (double)s;
        if(timeTaken <= t) {
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35692
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();

			if ( h==0 && w==0 ) break;

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					sb.append("#");
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}

}

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

using namespace std;

int main()
{
	//freopen("input14.txt","r",stdin);freopen("output14.txt","w",stdout);
	string a;
	bool q=true;
	int b[26]={0},i,t;
	cin>>a;
	for (i=0;i<a.length();i++){
		t=a[i]-'0';
		t-=49;
		b[t]++;
	}
	for (i=0;i<26;i++){
		if (b[i]%2!=0){
			q=false;
			cout<<"No";
			break;
		}
	}
	if (q==true){
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = a.copy()

def gcd(a, b):
  if b > a:
    a, b = b, a
  a, b = b, a % b
  if b == 0:
    return a
  else:
    return gcd(a,b)
def mcd(a, b):
  return a * b // gcd(a, b)

m = a.pop()
while a:
  t = a.pop()
  m = mcd(m, t)

print (sum([(m-1) % i for i in b])) 

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

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

	int X[10][10], count = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}

	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			float insqrt = 0;
			for (int k = 0; k < D; k++) {
				insqrt += pow(X[i][k] - X[j][k], 2);
			}

			float sq = sqrt(insqrt);
			if (fmod(sq, 1.0F) == 0) {
				count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 512
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) {
		cout << "-1\n";
		return 0;
	}
	int m = n - 1 + (n - 1) * (n - 2) / 2 - k;
	cout << m << '\n';
	for (int i = 1; i < n; i++)
		cout << i << ' ' << n << '\n';
	m -= n - 1;
	for (int i = 1; i < n; i++)
		for (int j = i + 1; j < n; j++) {
			if (m-- == 0)
				return 0;
			cout << i << ' ' << j << '\n';
		}
	return 0;
}
	

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N;
int h[100010];
int dp[100010];


signed main(){
    cin >> N;
    rep(i, 0, N) cin >> h[i];

    fill(dp, dp+N, INF32);
    dp[0] = 0;
    rep(i, 0, N) chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1])), chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2]));

    cout << dp[N-1] << endl;

    return 0;
}

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

constexpr int64_t INF = 1e12;

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

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

    int N; cin >> N;
    int64_t W; cin >> W;
    vector<int64_t> ws(N);
    vector<int> vs(N);
    REP(i, N) cin >> ws[i] >> vs[i];

    int total_value = 0;
    REP(i, N) total_value += vs[i];

    // dp[i][v]: i番目までの品物を使って価値の合計をvにするときの重さの総和の最小値
    vector dp(N, vector(total_value+1, int64_t()));
    dp[0][0] = 0;
    FOR(v, 1, total_value+1) {
        dp[0][v] = (vs[0] == v) ? ws[0] : INF;
    }
    FOR(i, 1, N) REP(v, total_value+1) {
        dp[i][v] = dp[i-1][v];
        if (v-vs[i] >= 0) {
            dp[i][v] = min(dp[i][v], dp[i-1][v-vs[i]] + ws[i]);
        }
    }

    int ans = 0;
    REP(v, total_value+1) if (dp[N-1][v] <= W) {
        ans = v;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 82228
from collections import defaultdict

d1 = defaultdict(int)
d2 = defaultdict(int)

n = int(input())

for i in range(1,n+1):
    si = str(i)
    f = si[0]
    l = si[-1]
    if f == l:
        d1[(f,l)]+=1
    else:
        d2[(f,l)]+=1

ans = 0
for v in d1.values():
    if v == 1:
        ans += 1
    else:
        ans += v**2

for v in list(d2.keys()):
    ans += d2[v]*d2[(v[1],v[0])]*2
    d2[v] = 0

print(ans)

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

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(nullptr);
  	int n; string s;
  	cin >> n >> s;
  	int a = 0, b = n - 1, ans = 0;
  	while (a < b) {
    	if (s[a] == 'R') { a++; continue; }
      	if (s[b] == 'W') { b--; continue; }
      	ans++;
      	a++;
      	b--;
    }
  	cout << ans << "\n";
  	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



    int main(){
        ll N;
        cin>>N;
        ll ans=0;
        for(ll A=1;A<N;A++){
            ll B=N/A;
            if(N%A==0){
                B--;
            }
            ans+=B;
        }
        cout<<ans<<endl;

    }

Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
struct date{
    int x,y;
};
int main(){
    int n;
    cin >> n;
    int end=n;
    while(n--){
        string field[8];
        for(int i = 0; i < 8; i++){
            cin >> field[i];
        }
        int h,w;
        cin >> w >> h;
        date start = {w-1,h-1};
        field[h-1][w-1] = '0';
        queue<date> Q;
        Q.push(start);
        while(!Q.empty()){
            date d = Q.front();
            Q.pop();
            int dx[] = {1,-1,0,0,2,-2,0,0,3,-3,0,0},dy[] = {0,0,1,-1,0,0,2,-2,0,0,3,-3};
            for(int i = 0; i < 12; i++){
                int px = d.x+dx[i],py = d.y+dy[i];
                if(px < 0 || py < 0 || py >= 8 || px >= 8)continue;
                if(field[py][px] == '1'){
                    field[py][px] = '0';
                    date next = {px,py};
                    Q.push(next);
                }
            }
        }
        cout << "Data " << (end-n) << ":" << endl;
        for(int i = 0; i < 8; i++)cout << field[i] << endl;
    }
    return 0;
}

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

#pragma warning(disable:4996)
using namespace std;

using ld=long double;
const ld eps=1e-9;


int main() {
	long long int K;cin>>K;
	string st;cin>>st;
	int N=st.size();
	vector<vector<vector<long long int>>>dp(N+11,
		vector<vector<long long int>>(N+11,vector<long long int>(2,2e9)));
	dp[0][0][0]=0;
	for (int l = 0; l < N; ++l) {
		for (int cnt = 0; cnt < N; ++cnt) {


			for (int type = 0; type < 2; ++type) {
				if (type == 1) {
					if (st[l] == '+') {
						dp[l + 1][cnt][0] = min(dp[l + 1][cnt][0], dp[l][cnt][type]);
					}
					else {
						dp[l + 1][cnt+1][0] = min(dp[l + 1][cnt+1][0], dp[l][cnt][type]);
					}
				}
				else {
					for (int len = 1; len <= min (10,N-l); ++len) {
						string ast = st.substr(l, len);

						int dame_cnt = 0;
						for (int j = 0; j < len; ++j) {
							if (j == 0 && len != 1) {
								if (ast[j] == '0') {
									ast[j] = '1';
									dame_cnt++;
								}
								if (ast[j] == '+') {
									ast[j] = '1';
									dame_cnt++;
								}
							}
							if (ast[j] == '+') {
								ast[j] = '0';
								dame_cnt++;
							}
						}

						int change_cnt = dame_cnt;
						int k=0;
						
						while (true) {
							long long int num=stoll(ast);
							dp[l+len][cnt+change_cnt][1]=
								min(dp[l+len][cnt+change_cnt][1],
									dp[l][cnt][0]+num);

							if(k==len)break;
							while (true) {
								if (k == len)break;
								if (k == 0 && len != 1) {
									if (ast[k] == '1') {
										k++;
									}
									else {
										ast[k]='1';
										k++;
										break;
									}
								}
								else {
									if (ast[k] == '0') {
										k++;
									}
									else {
										ast[k]='0';
										k++;
										break;
									}
								}
							}
							change_cnt++;
						}
					}
				}
			}
		}
	}

	int ans=1e9;
	for (int i = 0; i <= N; ++i) {
		if (dp[N][i][1] <= K) {
			ans=min(ans,i);
		}
	}
	if(ans>100000)ans=-1;
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 59208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
using ll = long long;
using namespace std;
using P = pair<int, int>;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  ll N, K;
  cin >> N >> K;
  mint answer = 0;
  for (int i = K; i <= N+1; i++){
      answer += (2*i*(N-(i-1))/2)+1;
  }
  cout << answer << endl;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    string T;
    cin >> S >> T;

    vector<vector<int> > vS(26, vector<int>()), vT(26, vector<int>());

    for (int i = 0; i < S.size(); i++) { vS[S[i] - 'a'].push_back(i); }
    for (int i = 0; i < S.size(); i++) { vT[T[i] - 'a'].push_back(i); }

    vector<string> sS, sT;
    for (auto v : vS) {
        string tmp = "";
        for (int vi : v) { tmp += to_string(vi); }
        sS.push_back(tmp);
    }
    for (auto v : vT) {
        string tmp = "";
        for (int vi : v) { tmp += to_string(vi); }
        sT.push_back(tmp);
    }

    sort(sS.begin(), sS.end());
    sort(sT.begin(), sT.end());

    if (sS == sT) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 5896
#include <cstdio>
using namespace std;

//?????????????????¢?????????
double dist(double x1,double y1,double x2,double y2){
	return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}
//??????
double dot_product(double x1,double y1,double x2,double y2){
	return x1*x2+y1*y2;
}
int main(){
	double x1,y1,x2,y2,xq,yq;
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)){
		double xr,yr,k,xs,ys;
		k=dot_product(x2-x1,y2-y1,xq-x1,yq-y1)/dist(x2,y2,x1,y1);
		//????????§?¨??????±???????????????
		xs=x1+k*(x2-x1);
		ys=y1+k*(y2-y1);
		//????????§?¨?
		xr=2*xs-xq;
		yr=2*ys-yq;
		printf("%.6lf %.6lf\n",xr,yr);
	}
}

Measured memory_bytes: 1084
n1 = int(input())

if n1 < 10:
    print(n1)
elif n1 <= 99:
    print(9)
elif n1 < 1000:
    print(9 + (n1 - 99))
elif n1 <= 9999:
    print(909)
elif n1 < 100000:
    print(909 + (n1 - 9999))
else:
    print(90909)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;

int main()
{
	in >> N;
	for (LL h = 1; h <= 3500; ++h)
	{
		for (LL w = 1; w <= 3500; ++w)
		{
			if ((4 * h*w - N * (w + h)) == 0) continue;
			LL n = N * h*w / (4 * h*w - N * (w + h));
			if (4 * h * w * n == N * n * w + N * h * w + N * h * n && n > 0)
			{
				out << h << " " << n << " " << w << std::endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
lst=list(map(int,input().strip().split()))[:n]
count=0 
for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if(lst[i]!=lst[j] and lst[j]!=lst[k] and lst[k]!=lst[i]):
                if (lst[i] +lst[j] > lst[k] and 
                    lst[i] + lst[k] > lst[j] and 
                    lst[k] + lst[j] > lst[i]): 
                    count += 1
print(count)

Measured memory_bytes: 9140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll n;
    cin >> n;

    // 2lごとでやすいものをかう
    cout << (n/2) * min(a*8, min(b*4, min(c*2, d))) + n%2 * min(a*4, min(b*2, c)) << endl;
    
    
}




Measured memory_bytes: 256
/* B Partition */

#include<stdio.h>
int n; /* 1<=n<=100000 */

int Partition(int A[], int q, int r);

int main(){
  int i;
  int q;

  scanf("%d",&n);
  int A[n];

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=Partition(A, 0, n-1);

  for(i=0;i<n-1;i++){
    if(q==i)printf("[%d] ",A[i]); /* to print [] */
    else printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);

  return 0;
}


int Partition(int A[], int p, int r){
  int i, j, x;
  int temp;

  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      temp=A[i]; /* exchange */
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1]; /* exchange */
  A[i+1]=A[r];
  A[r]=temp;
  return i+1;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int N;
	double sum = 0;
	int A[1100];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum += 1. / A[i];
	}
	
	double reverse = 1. / sum;
	cout << reverse << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin>>c;
    if(c-'A'>26) cout<<"a\n";
    else cout<<"A\n";
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    int m = 1 << n;
    VI a(m), b(m);
    REP(i,m) a[i] = in();
    int ans = 0;
    REP(mask,m){
        if (a[mask]){
            if (!b[mask]) ans++;
            REP(i,n) b[mask | (1<<i)] = 1;
        }else{
            if (b[mask]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
    long long N,K; cin>>N>>K;
    long long ans;
    if(K%2!=0){
        long long a=N/K;
        ans=a*a*a;
    }else{
        long long a=N/K;
        ans=a*a*a;
        long long b=2*N/K;
        b-=a;
        ans+=b*b*b;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


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

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

struct AB{
    ll A;
    ll B;
};

int f(ll x){
    int keta = 1;
    while(x >= 10){
        x /= 10;
        keta++;
    }

    return keta;
}

int main(){

    long long n;
    cin >> n;
    AB ab[int(1e5 + 50)];
    double root_n = sqrt(n) + 10;
    int root_int = int(root_n);
    int cnt = 0;

    for(int i=1; i<root_int; i++){
        if(n % i == 0){
            ab[cnt].A = i;
            ab[cnt].B = n / i;
            cnt++;
        }
    }

    int mx = 0;
    int min_keta = 1e5 + 10;
    int keta = 0;
    for(int j=0; j<cnt; j++){
        if(mx < ab[j].A || mx < ab[j].B){
            keta = max(f(ab[j].A), f(ab[j].B)); //桁の大きいほうを取る
            if(min_keta > keta) min_keta = keta; //桁の大きいほうの最小値を求める
        }
    }

    cout << min_keta << endl;

}

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

char a[100005];
int x=0,y=0;
int ans=0;

int main()
{
    cin>>a;
    for (int i=0;i<sizeof(a);i++)
    {
        if (x==y)
        {
            x++;
            if (a[i]=='p') ans--;
        } 
        else
        {
            y++;
            if (a[i]=='g') ans++;
        } 
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  string str;
  cin >>str;
  
  int cnt=0;
  for(int i=0; i+2<N; i++){
    string cut=str.substr(i, 3);
    if(cut=="ABC") cnt++;
  }
  cout << cnt <<endl;
}

Measured memory_bytes: 256
// 怪文書 / Dubious Document
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int a[26][50];
string s;

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        for(int j=0;j<s.size();j++){
            a[s[j]-'a'][i]++;
        }
    }
    for(int i=0;i<26;i++){
        sort(a[i],a[i]+n);
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<a[i][0];j++){
            cout<<char(i+'a');
        }
    }
}

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

int main(){
  int t;
  int b;
  
  while(scanf(" %d",&t), t!=0){
    for(int i=0;i<9;i++){
      scanf(" %d",&b);
      t -= b;
    }
    printf("%d\n",t);
  } 
  
  return 0;
}

Measured memory_bytes: 2616
N=int(input())
import sys
sys.setrecursionlimit(10**6)
T=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int, input().split())
    T[a-1].append((b-1,c))
    T[b-1].append((a-1,c))

Q,K=map(int, input().split())
D=[-1]*N
D[K-1]=0
def dfs(start, nowd):
    to=T[start]
    for t in to:
        next_node,c=t
        if D[next_node]!=-1:
            continue
        nextd=nowd+c
        D[next_node]=nextd
        dfs(next_node, nextd)
dfs(K-1,0)
# print(D)
for i in range(Q):
    x,y=map(int, input().split())
    print(D[x-1]+D[y-1])


Measured memory_bytes: 136108
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

string solve() {
  in<int> N, M;
  vector<pair<int,int>> sc(M);
  
  for (auto&& i : sc){
    cin >> i.first >> i.second;
    i.first--;
  }
  
  string r(N, '*');

  for (auto& i : sc) {
    if (r[i.first] != '*' && r[i.first] != i.second + '0')
      return "-1";
    else
      r[i.first] = i.second + '0';
  }
  
  if (N==1 && (r[0] == '0' || r[0] == '*'))
    return "0";
  if (r[0] == '0')
    return "-1";
  else if (r[0] == '*')
    r[0] = '1';
  
  for (int i = 1;i <N;i++) {
    if (r[i] == '*')
      r[i] = '0';
  }

  return r;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>
 
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
 
#define pb(x) push_back(x)  
#define rep(i,n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define len(p) (sizeof(p)/sizeof(*p))
#define debug(x) cerr << #x << ": " << x << '\n'; 
// #define int long long
 
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
template <class T> void print(T x){ cout << x << '\n'; }
 
signed main(void){
    int n, m;
    cin >> n >> m;
    double t = 0, lastT = -1;
    double p = 1, q = 1 / pow(2, m);
    int oneT = (100*(n-m) + 1900*m);
    int times = 1;
    while(t - lastT > 0.0001){
        lastT = t;
        // print(lastT);
        // print(oneT * p * q);
        t += times++ * oneT * p * q;
        p *= (1-q);
    }
    print(t);

    
}



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

int main()
{

    int n;
    cin>>n;

    if(n%10==3)
        cout<<"bon"<<endl;
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
        cout<<"pon"<<endl;
    else
        cout<<"hon"<<endl;
        
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node t[100005];
int n,D[100005];

int rec(int u,int p){
  D[u] = p;
  if(t[u].r != NIL)rec(t[u].r,p);
  if(t[u].l != NIL)rec(t[u].l,p+1);

}

int main(){

  int i,j,d,v,c,l,r;

  // printf("aaaaaaaa\n");
  
  scanf("%d",&n);
  for(i=0;i<n;i++)t[i].p=t[i].l=t[i].r = NIL;
  
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)t[v].l=c;
      else t[l].r=c;
      l=c;
      t[c].p=v;
    }
  }

  for(i=0;i<n;i++){
    if(t[i].p==NIL)r=i;
  }

  rec(r,0);
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,t[i].p,D[i]);

    if(t[i].p==NIL)printf("root, ");
    else if(t[i].l==NIL)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(j=0,c=t[i].l;c != NIL;j++,c = t[c].r){
      if(j)printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }
  return 0;
}



Measured memory_bytes: 6428
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1 = 1e5 + 5;
const int MX2 = 1e6 + 5;
const li inf = 4e18;
const li mod = 1e9 + 7;

li power(li a, li b) { li res = 1; while (b) { if (b % 2) res = (res * a) % mod;
a = (a * a) % mod; b /= 2; } return res; }

li mmi(li a) { return power(a, mod - 2); }

li cntbit(li n) { li cnt = 0; while (n) { n &= (n - 1); cnt++; } return cnt; }

int n;
int x[105], y[105], h[105];

void solve() {
    cin >> n;
    int mini = 500;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i] >> h[i];
        mini = min(mini, x[i] + y[i]);
    }
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            set<int> st;
            for (int i = 1; i <= n; i++) {
                int d1 = abs(cx - x[i]);
                int d2 = abs(cy - y[i]);
                st.insert(h[i] + d1 + d2);
            }
            int H = *st.begin();
            if (H < 1) continue ;
            int ok = 1;
            for (int i = 1; i <= n; i++) {
                if (max(0, H - abs(cx - x[i]) - abs(cy - y[i])) != h[i]) ok = 0;
            }
            if (ok) {
                cout << cx << " " << cy << " " << H;
                return ;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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


//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}



int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll lc=lcm(c,d);
    ll ans=b-b/c-b/d+b/lc-(a-1)+(a-1)/c+(a-1)/d-(a-1)/lc;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
const nmax=200010;
type ary=array[1..nmax] of 0..1;
var N,i,j,k,latter,sum,count:int64;
    a,ans:ary;
begin
read(N);latter:=0;count:=0;
for i := 1 to N do 
 begin read(a[i]);
  if i > N div 2 then 
   begin 
    ans[i]:=a[i];
    inc(latter);
    if ans[i]=1 then inc(count)
   end
  end;
for i := (N-latter) downto 1 do
 begin
  sum:=0;
  for j := 2 to N do
   if i*j > N then break 
   else sum:=sum+ans[i*j];
  ans[i]:=(sum+a[i]) mod 2;
  if ans[i]=1 then inc(count);
 end;
writeln(count);
for i := 1 to N do
 if ans[i]=1 then write(i,' ');
end.

Measured memory_bytes: 1280
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn :: IO Int
    a1 <- fmap read . words <$> getLine :: IO [Int]
    a2 <- fmap read . words <$> getLine :: IO [Int]
    let s = sum a1 + sum a2
    let ds = do
            i <- [1 .. n]
            let d1 = sum $ drop i a1
            let d2 = sum $ take (i - 1) a2
            return (d1 + d2)
    print $ s - minimum ds

Measured memory_bytes: 1020
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
  // cin>>t;
    while(t--)
    {  
       int a[3];
       for(int i=0;i<3;i++)
       cin>>a[i];
       swap(a[0],a[1]);
       swap(a[0],a[2]);
       print(a,3);
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int N = 0, head = 1, tail = 1, a = 0, b = 0, digit = 0, count = 0, HT[10][10];
    cin >> N;
    digit = log10(N)+1;
    for(head = 1 ; head < 10 ; head++){
        for(tail = 1; tail < 10; tail++){
            HT[head][tail] = 0;
            for(int i = 0 ; i < digit ; i++){
                a = head;
                b = 0;
                unsigned long int max = head+1;
                if(i > 0){
                    for(int j = 0 ; j < i ; j++){
                        a *= 10;
                        max *= 10;
                    }
                    a += tail;
                    max -= 1;
                }else if(head != tail){
                    continue;
                }
                if(a > N){
                    break;
                }
                while(a <= N){
                    HT[head][tail]++;
                    a += 10;
                    if(a > max){
                        break;
                    }
                }
            }
        }
    }
    for(int i = 1 ; i < 10 ; i++){
        for(int j = 1 ; j < 10 ; j++){
            count += (HT[i][j] * HT[j][i]);
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
  int P, Q, R;
  cin >> P >> Q >> R;
  int a,b,c;
  a=P+Q;
  b=Q+R;
  c=R+P;
  cout <<  min(a,min(b,c)) << endl;
  }

Measured memory_bytes: 256
n,c = map(int,input().split())
program = [list(map(int,input().split())) for i in range(n)]
time = [0 for i in range(10**5+1)]

program.sort()
program.sort(key = lambda x: x[2])

for i in range(1,n):
    if program[i][2]==program[i-1][2] and program[i][0]==program[i-1][1]:
        program[i][0] = program[i-1][0]
        program[i-1][0] = None

for i in range(n):
    if program[i][0] == None:
        continue
    time[program[i][0]-1] += 1
    time[program[i][1]] -= 1

count = 0
max_count = 0

for i in range(10**5+1):
    count += time[i]
    max_count = max(max_count,count)

print(max_count)

Measured memory_bytes: 76248
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<map>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  SORT(A);
  ll count=1;
  FOR(i,1,n){
    if(A[i]!=A[i-1]) count++;
  }
  vpll B(count);
  B[0].se=A[0];
  B[0].fi++;
  ll now=0;
  FOR(i,1,n){
    if(A[i-1]!=A[i]){
      now++;
      B[now].se=A[i];
      B[now].fi++;
    }
    else B[now].fi++;
  }
  ll ans=0;
  FOR(i,0,count){
    if(B[i].se<B[i].fi) ans+=B[i].fi-B[i].se;
    else if(B[i].fi<B[i].se) ans+=B[i].fi;
  }
  co(ans)
}

Measured memory_bytes: 2560
#include <iostream>

int main()
{
    int in_second; //??\??????????????????S 
    int out_hour, out_minute, out_second; //?????????h:m:s

    //??\???
    std::cin >> in_second;

    //?????????????¨????
    out_second = in_second % 60; 
    out_minute = (in_second /60) % 60; 
    out_hour = (in_second / 60) /60;
    //??????
    std::cout << out_hour << ":" << out_minute << ":" << out_second << std::endl;

    return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1e5+10;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

struct Edge{
    i32 To;
    Edge *Nxt;
    Edge(i32 To_,Edge *Nxt_):To(To_),Nxt(Nxt_) {}
}*Edg[MAXN];
inline void addedge(i32 u,i32 v){
    Edg[u]=new Edge(v,Edg[u]);
    Edg[v]=new Edge(u,Edg[v]);
}
i32 N;
ar Dis,Pre;
priority_queue<pii> pq;

inline void pre(){
    N=read();
    f(i,1,I,read()) addedge(read(),read());
    f(i,1,I,N) Dis[i]=0x3f3f3f3f;
    Dis[1]=0;
    pq.push( pii(1,0) );
}

inline bool dijkstra(){
    while( pq.size() ){
        pii tmp=pq.top(); pq.pop();
        if(-tmp.second>Dis[tmp.first]) continue;
        for(Edge *Vec=Edg[tmp.first];Vec;Vec=Vec->Nxt)
            if(Dis[Vec->To]>Dis[tmp.first]+1)
                pq.push( pii(Vec->To, -(Dis[Vec->To]=Dis[tmp.first]+1) ) ),Pre[Vec->To]=tmp.first;
    }
    f(i,1,I,N)
        if(Dis[i]==0x3f3f3f3f)
            return 0;
    return 1;
}

int main(){
    pre();
    if( dijkstra() ){
        print("Yes\n");
        f(i,2,I,N) print(Pre[i]),print('\n');
    }
    else print("No");
    output();
    return 0;
}

Measured memory_bytes: 20684
#include<stdio.h>

int main(){
  int N,i,j,key;
  int A[1000];

  scanf("%d",&N);

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

  for(j=0 ; j<N-1; j++) printf("%d ",A[j]);
  printf("%d\n",A[N-1]);

  for(i=1 ; i<N ; i++){
    
    key = A[i];
    j = i - 1;

    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }

    A[j+1] = key;

    for(j=0 ; j<N-1; j++) printf("%d ",A[j]);
    printf("%d\n",A[N-1]);
  }

  return 0;
}

Measured memory_bytes: 600
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

N, A, B = map(int, input().split())
S = input()

P = 0
Pb = 0
for i in range(len(S)):
    if S[i] == 'a':
        if P < A + B:
            P += 1
            print("Yes")
        else:
            print("No")
    elif S[i] == "b":
        if P < A + B and Pb < B:
            P += 1
            Pb += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 9280
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
string S;
cin >> S;
int ans=0;
int a=0;
bool checker=false;
for(int i=0;i<S.size();i++)
{
  if(!checker)a=0;
if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T')
{
  if(checker);
  else checker=true;
  a++;
}else if(checker)checker=false;
ans=max(ans,a);
}
cout << ans;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop, heapify
import math
import itertools as it
from collections import deque 


def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

H, W = inpl()
ch, cw = inpl()
dh, dw = inpl()
ch -= 1
cw -= 1
dh -= 1
dw -= 1

S = []
for i in range(H):
    S.append(input())

dist = []
INF = 1001001001
for i in range(H):
    dist.append([INF for i in range(W)])

q = deque([])
q.append((ch, cw))
dist[ch][cw] = 0
while q:
    h, w = q.popleft()
    # 歩き回る
    for i, j in ((1,0),(-1,0),(0,1),(0,-1)):
        if not 0 <= h + i < H:
            continue
        if not 0 <= w + j < W:
            continue
        if S[h+i][w+j] == '#':
            continue
        if dist[h][w] < dist[h+i][w+j]:
            dist[h+i][w+j] = dist[h][w]
            q.appendleft((h+i, w+j))
    # ワープ
    for i in range(-2, 3):
        for j in range(-2, 3):
            if not 0 <= h + i < H:
                continue
            if not 0 <= w + j < W:
                continue
            if S[h+i][w+j] == '#':
                continue
            if dist[h][w] + 1 < dist[h+i][w+j]:
                dist[h+i][w+j] = dist[h][w] + 1
                q.append((h+i, w+j))

print(dist[dh][dw] if dist[dh][dw] != INF else -1)



# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)



Measured memory_bytes: 88692
/*
    coder:xxjAc
    name:
    time:2017/8/6
*/
#include <sstream>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <string.h>
#include <assert.h>
#include <time.h>
#include <fstream>
#include <numeric>
#include <cstring>
using namespace std;
int H,W,n;
int ans[107][107];
int main(){
	scanf("%d%d",&H,&W);
	scanf("%d",&n);
	int c,x=0,y=0;
	bool f=false;
	for (int i=1;i<=n;i++){
		cin>>c;
		for (int j=0;j<c;j++){
			ans[x][y]=i;
			if (!f){
				if (y==W-1){
					x++;
					f=true;
				}
				else{
					y++;
				}
			}
			else{
				if (y==0){
					x++;
					f=false;
				}
				else{
					y--;
				}
			}
		}
	}
	for (int i=0;i<H;i++){
		for (int j=0;j<W;j++){
			if (j!=W-1){
				printf("%d ",ans[i][j]);
			}
			else{
				printf("%d\n",ans[i][j]);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384