akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

struct edge { int to, cost; }; 
vector<edge> G[500009];
int N,M;
map<pii,int> id;
int cnt=0;

int dijkstra(int s, int t) {
    
    vector<int> d(cnt,INF);
    priority_queue< pii, vector<pii>, greater<pii> > que;   // first:cost second:頂点 cost基準の昇順
    que.push({0,s});
    d[s] = 0;
    
    while(!que.empty()){
        pii p = que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        rep(i,G[v].size()){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                que.push({d[e.to],e.to});
            }
        }
    }
    return d[t];
}

int getid(int node,int com){
    pii p={node,com};
    if(id.count(p)) return id[p];
    return id[p]=cnt++;
}

void addedge(int u,int v,int c){
    u=getid(u,c), v=getid(v,c);
    G[u].push_back({v,0});
    G[v].push_back({u,0});
}

void addedge2(int u,int c){
    int v=getid(u,-1);
    u=getid(u,c);
    G[u].push_back({v,0});
    G[v].push_back({u,1});
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,M){
        int u,v,c;
        cin>>u>>v>>c;
        addedge(u,v,c);
        addedge2(u,c);
        addedge2(v,c);
    }
    
    int s=getid(1,-1);
    int t=getid(N,-1);
    int ans=dijkstra(s,t);
    if(ans==INF) ans=-1;
    cout1(ans)
}

Measured memory_bytes: 65268
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    for(int l=0;l<m;l++){
        cin>>a[l];
    }
    for(int i=0;i<m;i++){
        if(a[i]<x&&a[i+1]>x){
            cout<<min(i+1,m-i-1)<<endl;
            return 0;
        }
        if(i==m-1){
            cout<<0<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int n,L;
	string s;
	vector<string>v;
	cin>>n>>L;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		v.pb(s);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
	{
		cout<<v[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int x = scanner.nextInt();
        int a = scanner.nextInt();
        writer.println(x < a ? 0 : 10);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21332
from collections import deque
H,W = map(int,input().split())
S = list(list(input())for _ in range(H))
ans = 0
for sh in range(H):
    for sw in range(W):
        if S[sh][sw] == "#":
            continue
        queue = deque([[sh,sw]])
        cost = [[10000]*W for i in range(H)]
        cost[sh][sw] = 0
        while queue:
            h,w = queue.popleft()
            for nh,nw in [[h-1,w],[h,w-1],[h+1,w],[h,w+1]]:
                if not (0 <= nh < H and 0 <= nw < W):
                    continue
                if S[nh][nw] == '.' and cost[nh][nw] > cost[h][w]+1:
                    cost[nh][nw] = cost[h][w]+1
                    queue.append([nh,nw])
                    ans = max(ans,cost[nh][nw])
print(ans)

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

int main () {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  vector<int> data = {a, b, c, d, e};
  vector<vector<int>> table(5, vector<int>(5));
  for (int i = 0; i < 5; i++) {
    for (int j =0; j < 5; j++) {
      int s = data.at(i) - data.at(j);
      if (s < 0) {
        s *= -1;
      }
      table.at(i).at(j) = s;
    }
  }
  bool answer = true;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      if (table.at(i).at(j) > k) {
        answer = false;
      }
    }
  }
  
  if (answer) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int r=Integer.parseInt(scan.next());
    		
    		if (r<1200) {
    			System.out.print("ABC");
    		}else if(r<2800){
    			System.out.print("ARC");
    		}else {
    			System.out.print("AGC");
    		}
     
    }
    }
// end 

Measured memory_bytes: 23124
/*
 * d.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d:%d:%d\n", s / 3600, (s / 60) % 60, s % 60);
  return 0;
}

Measured memory_bytes: 1144
N,money = list(map(int,input().split()))
for i in range(0,N+1):
    for j in range(0,N-i+1):
        k = N-i-j
        if i * 10000 + j * 5000 + k * 1000 == money:
            print(i,j,k)
            exit()
print(-1,-1,-1)

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

int main()
{
    int h, w, i, j;
    cin>>h>>w;
    vector<int> v1, v2;
    bool res;

    string arr[h];

    for(i=0;  i<h; i++){
        cin>>arr[i];
    }
    for(i=0; i<h; i++){
        res = true;
        for(j=0; j<w; j++){
            if('.' != arr[i][j]){
                res = false;
            }

        }
        if(res == false)
            v1.push_back(i);
    }

    for(j=0; j<w; j++){
        res = true;
        for(i=0; i<h; i++){
            if('.' != arr[i][j])
                res = false;
        }
        if(res == false)
            v2.push_back(j);
    }

    for(i=0; i<h; i++){
        if( (find(v1.begin(), v1.end(), i) != v1.end() )){

            for(j=0; j<w; j++){
                if(find(v2.begin(), v2.end(), j) != v2.end()){

                    cout<<arr[i][j];
                }

            }
            cout<<endl;
        }

    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

int main (int argc, char* argv[]) {
	vector<int> nums(3);
	for (int i = 0; i < 3; i++) {
		cin >> nums[i];
	}
	sort(nums.begin(), nums.end());
	cout << (nums.back() * 10 + nums[0] + nums[1]) << endl;
}


Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

a, b = list(map(int, sys.stdin.buffer.readline().split()))
print( (a -1) * (b - 1))


Measured memory_bytes: 13464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int n,m; cin>>n>>m;
    priority_queue<ll, vector<ll>, greater<ll>> a;
    ll ans = 0;
    for(int i=0; i<n; i++){
        int tmp; cin>>tmp;
        a.push(tmp);
        ans += tmp;
    }
    vector<pair<ll,ll>> vec(m);
    for(int i=0; i<m; i++){
        int b,c; cin>>b>>c;
        vec[i] = make_pair(c,b);
    }
    sort(ALL(vec), greater<pair<ll,ll>>());
    for(int i=0; i<m; i++){
        int b=vec[i].second, c=vec[i].first;
        for(int j=0; j<b; j++){
            if(a.top()<c){
                ans -= a.top();
                a.pop();
                a.push(c);
                ans += c;
            }
            else{
                OUT(ans);
                return 0;
            }
        }
    }
    OUT(ans);
}

Measured memory_bytes: 2676
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        long long n,m;
        scanf("%lld %lld",&n,&m);

        long long num = 0;
        long long sum = n*m;
        long long s = sqrt(sum);
        if(m==n)
        {
            num = (s-1)*2;
        }
        else
        {
            long long hh = s*(s+1);

            if(hh>=sum)
                num = (s-1)*2;
            else
                num = (s)*2-1;
            if(s*s == sum)
            {
                if(hh>=sum)
                    num = (s-1)*2-1;
                else
                    num = (s)*2;
            }
        }
        printf("%lld\n",num);
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def solve(s, t):
    cands = set()
    t0_idx_max = len(s) - len(t)
    for t0_idx in range(t0_idx_max + 1):
        if all(s[i + t0_idx] in (t[i], "?") for i in range(len(t))):
            cand_chars = list(s)
            for i in range(len(t)):
                cand_chars[i + t0_idx] = t[i]
            for i in range(len(cand_chars)):
                if cand_chars[i] == "?":
                    cand_chars[i] = "a"
            cand = "".join(cand_chars)
            cands.add(cand)
    return min(cands, default=None)


def main():
    s = input()
    t = input()
    res = solve(s, t)
    print("UNRESTORABLE" if res is None else res)


if __name__ == '__main__':
    main()


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

int main()
{

    long long Th,Ts,Ah,As;
    cin>>Th>>Ts>>Ah>>As;
    int i=0;


    while(1){
     Ah=Ah-Ts;
    if(Ah<=0){
        cout<<"Yes";
        break;
    }
     Th=Th-As;
    if(Th<=0){
        cout<<"No";
        break;
    }




    }



}



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

int main(){
    int n;
    cin >> n;
    vector<int> array(n);
    string s = "Yes";
    ll b = 0;
    ll max = -1;
    for(int i=0;i<n;i++){
        ll h;
        cin >> h;
        if(max - h > 1){
            s = "No";
            break;
        }
        if(max < h) max = h;
    }
    cout << s << endl;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],b[N],p[N],q[N],i,mn;
pair<int,int*>c[N*2];
long long s[N*2],ans=1ll<<60,t,sa;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d",a+i,b+i),c[i*2-1]=make_pair(a[i],p+i),c[i*2]=make_pair(b[i],q+i),sa+=a[i];
	sort(c+1,c+n*2+1);for(i=1;i<=n*2;++i)*c[i].second=i,s[i]=s[i-1]+c[i].first;
	ans=min(ans,min(sa,s[n*2]-sa));
	for(i=1;i<=n;++i){
		int x=p[i],y=q[i];if(x>y)swap(x,y);
		if(y<=n)ans=min(ans,s[n]);else if(x<=n-1)ans=min(ans,s[n-1]+c[y].first);
			else ans=min(ans,s[n-2]+a[i]+b[i]);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
  string a;
  cin >> a;
  if(a[2]==a[3]){
    if(a[4]==a[5]){
      cout << "Yes" << endl;
    }
    else{
    cout << "No" << endl;
  }
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

bool comp(pll a, pll b){
    return atan2(a.S, a.F) < atan2(b.S, b.F);
}

int main(){
    StarBurstStream

    int n;
    cin >> n;

    vector<pll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i].F >> a[i].S;

    sort(iter(a), comp);
    a.resize(2 * n);
    for(int i = n; i < 2 * n; i++) a[i] = a[i - n];

    ll ans = 0;
    for(int i = 0; i < n; i++){
        
        pll now = mp(0, 0);
        
        for(int j = 1; j <= n; j++){
            now.F += a[i + j].F;
            now.S += a[i + j].S;
            ans = max(ans, now.F * now.F + now.S * now.S);
        }

    }

    cout << fixed << setprecision(12) << sqrt(ans) << "\n";

    return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int A = scanner.nextInt();
		int B = scanner.nextInt();

		if ((A > 9 || A < 1) || (B > 9 || B < 1)) {
			System.out.println("-1");
		} else {
			System.out.println(A * B);
		}
	}
}

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

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

using namespace std;

int h,w,sum[3][50];
char c[51][51], color[] = {'W','B','R'};

void preprocess(int type) {
  rep(y,h) {
    sum[type][y] = ((y-1>=0)?sum[type][y-1]:0);
    rep(x,w) sum[type][y] += ( color[type] == c[y][x] );
  }
}

inline int calc(int type,int i,int j) { return sum[type][i] - sum[type][j]; }

void compute() {
  rep(i,3) preprocess(i);
  int mini = INT_MAX;
  rep(i,h-2) REP(j,i+1,h-1) mini = min(mini,(sum[1][i]+sum[2][i])+(calc(0,j,i)+calc(2,j,i))+(calc(0,h-1,j)+calc(1,h-1,j)));
  cout << mini << endl;
}

int main() {
  cin >> h >> w;
  rep(i,h) scanf(" %s",&c[i][0]);
  compute();
  return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

ll H,W,N;
map< pair<ll,ll> ,ll> cnt;
const int dx [] = {0,1,1,1,0,-1,-1,-1,0};
const int dy [] = {1,1,0,-1,-1,-1,0,1,0};

bool in_range(ll y,ll x){
	return y >= 2 && y <= H - 1 && x >= 2 && x <= W - 1;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W >> N;
	FOR(i,0,N){
		ll A,B;
		cin >> A >> B;
		FOR(j,0,9){
			ll y = A + dy [j],x = B + dx [j];
			if(in_range(y,x)){
				cnt [MP(y,x)]++;
			}
		}
	}
	
	vector<ll> ans(10);
	ans [0] = (H - 2) * (W - 2) - cnt.size();
	for(auto it : cnt){
		ans [it.second]++;
	}

	FOR(i,0,10){
		cout << ans [i] << endl;
	}

	return 0;
}


Measured memory_bytes: 56448
n, m = map(int, input().split())
switches = []
for i in range(m):
    switches.append(list(map(int, input().split())))

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

switches_pattern = []
for i in range(2**n):
    switches_pattern.append(list(map(int, format(i, "b").zfill(n))))

result = 0
for pattern in switches_pattern:
    light_bulb = True
    for i in range(m):
        bulb_count = 0
        for bulb_index in switches[i][1:]:
            if pattern[bulb_index - 1] == 1:
                bulb_count += 1
        if bulb_count % 2 != p[i]:
            light_bulb = False
        
    if light_bulb:
        result += 1

print(result)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),K=in();
	auto V=vecin<ll>(N);
	vector<ll> S(N+1,0),B(N*(N+1)/2,0);
	REP(i,N){
		S[i+1]=S[i]+V[i];
	}
	for(int i=1,index=0;i<=N;i++){
		for(int j=i;j<=N;j++){
			B[index++] = S[j]-S[i-1];
		}
	}
	sort(ALL(B),greater<ll>());
	int M=0;
	for(ll i=B[0];i;i>>=1LL){
		M++;
	}
	ll A=0;
	REP(i,M){
		ll Q=1LL<<(M-1-i);
		ll sum=0;
		REP(j,N*(N+1)/2){
			if(((A+Q)&B[j])==(A+Q)) sum++;
		}
		if(sum>=K) A+=Q;
	}
	out(A);
	return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    string s; int w; cin >> s >> w;
    for (int i = 0; i < s.size(); i += w) cout << s[i]; cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  int diff[N+1] = {}; 
  rep(i, N) { 
    if (S[i]=='I') diff[i+1]= diff[i] + 1; 
    else diff[i+1]= diff[i] - 1; 
  }
  int result = 0; rep(i, N+1) result = max(result, diff[i]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int K, X;

int main() {

    cin >> K >> X;

    if (K*500 >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

long long N, A[26], mod = 1000000007; string S;

int main() {
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) A[S[i] - 'a']++;

	long long ret = 1;
	for (int i = 0; i < 26; i++) { ret *= (A[i] + 1); ret %= mod; }
	cout << (ret + mod - 1) % mod << endl;
	return 0;
}

Measured memory_bytes: 512
N, M = map(int, input().split())
A = [None]*M

is_broken = [False] * (N+1)

for i in range(M):
    A[i] = int(input())
    is_broken[A[i]] = True

dp = [0] * (N+1)
dp[0] = 1

for i in range(1, N+1):
    if is_broken[i]:
        continue
    dp[i]  = (dp[i-1] + dp[i-2]) % (10**9 + 7)

print(dp[-1])

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long N;
  cin >> N;
  vector<long> A(N * 3);
  priority_queue<long, vector<long>, greater<long>> LQ;
  priority_queue<long> RQ;
  long l = 0, r = 0;
  for (int i = 0, a; i < N * 3 && cin >> a; i++) {
    A.at(i) = a;
    if (i < N) {
      LQ.push(a);
      l += a;
    }
    if (i >= N * 2) {
      RQ.push(a);
      r += a;
    }
  }
  vector<long> L = { l };
  for (int i = N; i < N * 2; i++) {
    long t = LQ.top();
    if (t >= A.at(i)) {
      L.push_back(l);
      continue;
    }
    l += A.at(i) - t;
    L.push_back(l);
    LQ.pop();
    LQ.push(A.at(i));
  }
  vector<long> R = { r };
  for (int i = N * 2 - 1; i >= N; i--) {
    long t = RQ.top();
    if (t <= A.at(i)) {
      R.push_back(r);
      continue;
    }
    r -= t - A.at(i);
    R.push_back(r);
    RQ.pop();
    RQ.push(A.at(i));
  }
  reverse(R.begin(), R.end());
  long ans = -2e18;
  for (int i = 0; i < N + 1; i++) {
    ans = max(ans, L.at(i) - R.at(i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 9496
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true)
    {
      int x = sc.nextInt();
      int y = sc.nextInt();

      if(x == 0 && y == 0) break;

      for(int i=0; i<x; i++){
        for(int j=0; j<y; j++){
          if(i % 2 == 0){
            out.printf(j%2 == 0 ? "#" : ".");
          }else{
            out.printf(j%2 == 0 ? "." : "#");
          }
        }
        out.println();
      }

      out.println();
    }
  }
}


Measured memory_bytes: 58644
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[200005];
LL sum[200005];

LL mx[2][2], mn[2][2];

int main(){
	int n;
	scanf("%d", &n);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
		sum[i] = sum[i-1]+a[i];
	}
	LL ans = 2e18;
	for(int i=2;i<=n-2;i++){
		memset(mx, -1, sizeof(mx));
		memset(mn, -1, sizeof(mn));
		LL smid = sum[i]/2;
		int lo = 1, hi = i-1, idx = -1;
		while(lo <= hi){
			int mid = (lo+hi)/2;
			if(sum[mid] <= smid) idx = mid, lo = mid+1;
			else hi = mid-1;
		}
		if(idx != -1){
			mn[0][0] = min(sum[idx], sum[i]-sum[idx]);
			mx[0][0] = max(sum[idx], sum[i]-sum[idx]);
		}
		lo = 1, hi = i-1, idx = -1;
		while(lo <= hi){
			int mid = (lo+hi)/2;
			if(sum[mid] >= smid) idx = mid, hi = mid-1;
			else lo = mid+1;
		}
		if(idx != -1){
			mn[0][1] = min(sum[idx], sum[i]-sum[idx]);
			mx[0][1] = max(sum[idx], sum[i]-sum[idx]);
		}

		smid = (sum[n]-sum[i])/2;
		lo = i+1, hi = n-1, idx = -1;
		while(lo <= hi){
			int mid = (lo+hi)/2;
			if(sum[mid]-sum[i] <= smid) idx = mid, lo = mid+1;
			else hi = mid-1;
		}
		if(idx != -1){
			mn[1][0] = min(sum[idx]-sum[i], sum[n]-sum[idx]);
			mx[1][0] = max(sum[idx]-sum[i], sum[n]-sum[idx]);
		}
		lo = i+1, hi = n-1, idx = -1;
		while(lo <= hi){
			int mid = (lo+hi)/2;
			if(sum[mid]-sum[i] >= smid) idx = mid, hi = mid-1;
			else lo = mid+1;
		}
		if(idx != -1){
			mn[1][1] = min(sum[idx]-sum[i], sum[n]-sum[idx]);
			mx[1][1] = max(sum[idx]-sum[i], sum[n]-sum[idx]);
		}
 
		for(int j=0;j<2;j++){
			if(mn[0][j] == -1) continue;
			for(int k=0;k<2;k++){
				if(mn[1][k] == -1) continue;
				LL c1 = max(mx[0][j], mx[1][k]);
				LL c2 = min(mn[0][j], mn[1][k]);
				ans = min(ans, c1-c2);
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>

using namespace std;

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

    int pos_a, pos_z;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A') {
            pos_a = i;
            break;
        }
    }

    for (int i = S.size() - 1; i >= 0; i--) {
        if (S[i] == 'Z') {
            pos_z = i;
            break;
        }
    }

    int ans = pos_z - pos_a + 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
int n,k,ni[4000001],jie[4000001],m,dp[2001][2001],mo;
long long mi(long long aa,long long bb)
{
	long long s=1;
	while(bb!=0)
	{
		if((bb%2)==1) s=(s*aa)%mo;
		aa=(aa*aa)%mo;
		bb=bb/2;
	}
	return(s);
}
int main()
{
	scanf("%d%d",&n,&k);
	mo=1000000007;
	m=n*k;
	jie[0]=1;
	for(int i=1;i<=m;i++)jie[i]=(1ll*jie[i-1]*i)%mo;
	ni[m]=mi(jie[m],mo-2);
	for(int i=m;i>=1;i--)ni[i-1]=(1ll*ni[i]*i)%mo;
	dp[0][0]=1;
	if(k==1) printf("1\n");
	else
	{
		k=k-2;
		for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			if(i!=j) dp[i][j+1]=(dp[i][j+1]+1ll*(n-j)*((((1ll*jie[m-j*k-j-1-i]*ni[m-j*k-j-1-k-i])%mo)*((1ll*ni[k]*dp[i][j])%mo))%mo))%mo;
			if(i<n)dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mo;
		}
		printf("%d\n",dp[n][n]); 
	}
} 

Measured memory_bytes: 46208
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int x, y ,z;
  scanf("%d%d%d", &x, &y, &z);
  printf("%d %d %d\n", z, x, y);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		System.out.println(s.compareTo("2019/04/30") < 1 ? "Heisei" : "TBD");
	}
}


Measured memory_bytes: 22604
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    A = list(map(int, input().split()))

    # 全探索余裕
    ans = float("inf")
    for i in range(-100, 100+1):
        cost = 0
        for j in range(N):
            # 全てiに書き換える
            cost += (i - A[j])**2
        ans = min(ans, cost)
    
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
const int N=2e5+5,mod=1e9+7;
 
int n,cnt;
ll modpow(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main(){
    map<pair<ll,ll>,pair<int,int> >m;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        ll a,b;
        cin>>a>>b;
        if(!a&&!b){
            cnt++;
            continue;
        }
        ll g=__gcd(a,b);
        a/=g,b/=g;
        if(b<0) a=-a,b=-b;
        if(a<=0) m[{b,-a}].second++;
        else m[{a,b}].first++;    
    }
    ll ans=1;
    for(auto u:m){
        ans=(ans*(mod+modpow(2,u.second.first)+modpow(2,u.second.second)-1)%mod)%mod;
    }
    cout<<(mod+ans+cnt-1)%mod;
    return 0;
}  

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

//constexpr long double PIL = 3.141592653589793238462643383279502884L;
//constexpr double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = (c + b - 1) / b;
	int y = (a + d - 1) / d;
	cout << (x <= y ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 2019;//1000000007;
int INF = 1001001001;

void solve()
{
	string s;cin >> s;
	reverse(all(s));
	int n = sz(s);
	vector<ll> a(n, 1);
	rep(i, n-1)
	{
		a[i+1] = 10 * a[i];
		a[i+1] %= MOD;	
	}
	rep(i, n)
	{
		a[i] *= int(s[i]-'0');
		a[i] %= MOD;
	}
	vector<ll> sum(n+1, 0);
	rep(i, n)
	{
		sum[i+1] = sum[i]+a[i];
		sum[i+1] %= MOD;
	}
	map<int,int> mp;
	rep(i, n+1)mp[sum[i]]++;
	ll ans = 0;
	for (auto e : mp)ans += e.second*(e.second-1)/2;
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 6624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

void CountingSort(vector<int> A, vector<int> &B, int k)
{
    vector<int> C;
    repi(i, k + 1, 0)
    {
        C.push_back(0);
    }
    repi(i, A.size(), 0)
    {
        C.at(A.at(i))++;
    }
    repi(i, k + 1, 1)
    {
        C.at(i) += C.at(i - 1);
    }
    for (int i = A.size() - 1; i >= 0; i--)
    {
        B.at(C.at(A.at(i))-1) = A.at(i);
        C.at(A.at(i))--;
    }
}

int main()
{
    int n, k = 0;
    cin >> n;
    vector<int> A(n, 0), B(n, 0);
    repi(i, n, 0)
    {
        cin >> A[i];
        k = max(A.at(i), k);
    }
    CountingSort(A, B, k);
    repi(i, n, 0)
    {
        cout << B.at(i) << ((i + 1) % n ? " " : "\n");
    }

    return 0;
}


Measured memory_bytes: 26372
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define M 605

using namespace std;

int n, m;
double f[M], a[M], ans;
vector<int>G[M];

double dfs(int u)
{
	if (u == n)
		return 0;
	if (f[u] != 0)
		return f[u];
	for (int v : G[u])
		f[u] += dfs(v);
	return f[u] = f[u] / G[u].size() + 1;
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		cin >> x >> y;
		G[x].push_back(y);
	}
	dfs(1);
	a[1] = 1;
	for (int i = 1; i < n; i++)							//经过第i个点的概率
		for (int j : G[i])
			a[j] += a[i] / G[i].size();
	for (int i = 1; i < n; i++)
		if (G[i].size() > 1)
		{
			double tmp = 0;
			for (int j : G[i])
				tmp += f[j];
			for (int j : G[i])
				ans = max(ans, a[i] * (f[i] - ((tmp - f[j]) / (G[i].size() - 1) + 1)));
		}
	printf("%.10f\n", f[1] - ans);

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdlib>
#include<cassert>
#include<random>
using namespace std;
int main(){
    long long N,H;
    cin >> N >> H;
    long long a[100001],b[100001];
    long long sa[100001],sb[100001];
    for(int i=0; i<100001; i++){
        a[i] = 0;
        b[i] = 0;
        sa[i] = 0;
        sb[i] = 0;
    }
    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i];
        sa[i] = a[i];
        sb[i] = b[i];
    }
    

    sort(sa,sa+100001,greater<long long>());
    sort(sb,sb+100001,greater<long long>());

    long long damage = 0;
    long long now = 0;
    long long ans = 0;
    while(damage < H){
        if(sa[0] <= sb[now]){
            damage += sb[now];
            now++;
            ans++;
        }
        else{
            damage += sa[0];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-


def main():
    n, large_t = map(int, input().split())
    cost = 10000

    for i in range(n):
        ci, ti = map(int, input().split())

        if ti <= large_t:
            cost = min(cost, ci)

    if cost != 10000:
        print(cost)
    else:
        print('TLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int haveyen = sc.nextInt();
		int money500 = haveyen / 500;
		int happy500 = money500 * 1000 ;
		int money5 = (haveyen - (money500 * 500)) / 5;
		int happy5 = money5 * 5;

		System.out.println(happy500 + happy5);
	}
}

Measured memory_bytes: 22868
n = int(input())
a = list(map(int, input().split()))

cnt=0
num=0
for tmp in a:
    if cnt%2==0:
        num+=tmp
    else:
        num-=tmp
    cnt+=1

ans=[]
ans.append(num)

for tmp in a:
    num = (tmp - (num/2))*2
    ans.append(num)

for i in range(n):
    print(int(ans[i]),end=" ")

Measured memory_bytes: 14616
import std.stdio;
import std.conv;
import std.string;
import std.array;

void main()
{
    ulong D = 1000000007;

    string S = readln.chomp;

    ulong[] b_mod = new ulong[13];
    b_mod[0] = 1;
    ulong[] c_mod;
    foreach (char c; S){
        c_mod = new ulong[13];

        for (int i = 0; i < 13; i++){
            if (c != '?'){
                int c_n = c - '0';
                int m = (i * 10 + c_n) % 13;
                c_mod[m] += b_mod[i];

                c_mod[m] %= D;
            } else {
                for (int j = 0; j < 10; j++){
                    int m = (i * 10 + j) % 13;
                    c_mod[m] += b_mod[i];

                    c_mod[m] %= D;
                }
            }
        }

        for (int i = 0; i < 13; i++) b_mod[i] = c_mod[i];
    }

    writeln(c_mod[5]);
}



Measured memory_bytes: 1448
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        int N = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            list.add(sc.nextInt());
        }

        Collections.sort(list);

        System.out.println(list.get(N-1) - list.get(0));
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<tuple>
#include<utility>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc107_b(){
    //入力
    int n;
    cin >> n;
    int cnt = 0;
    int ans = 0;
    
    //処理
    for(int i=1;i<=n;++i){
        if(i%2){
            for(int j=1;j<=i;++j){
                if(i%j ==0) cnt++;
            }
            if(cnt==8) ans++;
            cnt = 0;
        }
    }

    //出力
    cout << ans << enter;
    return 0;
}

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


Measured memory_bytes: 256
//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 8/3/2019

*/

#include <bits/stdc++.h>
using namespace std;
#define time cout << "\ntime: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;

    




int main(void){
	int n;
	cin >>n;
	int M[n][3];
	for(int i=0 ;i<n ;i++)
		for(int j=0 ; j<3 ;j++)
			cin >>M[i][j];

    for(int i=n-2 ; i>=0 ;i--){

    	M[i][0]=max(M[i+1][1],M[i+1][2])+M[i][0];
    	M[i][1]=max(M[i+1][0],M[i+1][2])+M[i][1];
    	M[i][2]=max(M[i+1][0],M[i+1][1])+M[i][2];

    }


    cout<< max(M[0][0],max(M[0][1],M[0][2]));
   return 0;
}


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

int main(void){
  ll N; cin >> N;
  vector<ll> a(N);
  vector<ll> b(N+1);
  ll ans = INT_MAX;
  for(ll i = 0; i < N; i++){
    cin >> a[i];
  }
  b[0] = 0;
  for(ll i = 0; i < N; i++){
    b[i+1] = a[i] + b[i];
  }

  for(ll idx = 1; idx <= N-1; idx++){
    ans = min(ans, abs((b[idx] - b[0]) - (b[N] - b[idx])));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int n, a[220];
vector<int> z;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i < n; i++) {
		z.push_back(1);
		for (int j = 1; j < n; j++) {
			if (a[j - 1] > a[j]) {
				z.push_back(n - 1);
				swap(a[j - 1], a[j]);
			}
			z.push_back(1);
		}
	}
	printf("%d\n", z.size());
	for (int i: z) {
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
lli h, w, a, b, c, d;

int main(void){
    cin >> h >> w >> a >> b >> c >> d;
    vector<vector<char>> m(h+2, vector<char>(w+2, '#'));
    vector<vector<lli>> dp(h+2, vector<lli>(w+2, 1e9));
    rep(i, h){
        string s;
        cin >> s;
        rep(j, w) m[i+1][j+1] = s[j];
    }
    deque<pair<lli, lli>> q;
    q.push_front({a, b});
    dp[a][b] = 0;
    while(!q.empty()){
        lli x, y;
        x = q.front().first;
        y = q.front().second;
        q.pop_front();
        lli nx, ny;
        //A
        rep(i, 4){
            nx = x+dx[i];
            ny = y+dy[i];
            if(m[nx][ny] == '#') continue;
            if(dp[nx][ny] <= dp[x][y]) continue;
            dp[nx][ny] = dp[x][y];
            q.push_front({nx, ny});
        }
        //B
        rep(i, 5){
            rep(j, 5){
                nx = x+i-2;
                ny = y+j-2;
                if(nx < 1 || nx > h || ny < 1 || ny > w) continue;
                if(m[nx][ny] == '#') continue;
                if(dp[nx][ny] <= dp[x][y]+1) continue;
                dp[nx][ny] = dp[x][y]+1;
                q.push_back({nx, ny});
            }
        }
    }
    if(dp[c][d] < 1e9) cout << dp[c][d] << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 12620
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
using namespace std;

bool done[222222];
int main() {
    string S;
    cin>>S;
    int L = S.size();
    
    set<pair<int,int> > occ;
    for(int i=0;i<L-1;i++) {
        if (S[i]=='S' && S[i+1]=='T') {
            occ.insert(make_pair(i,i+1));
        }
    }
    
    for(int i=0;i<L;i++) {
        done[i]=false;
    }
    
    while(!occ.empty()) {
        pair<int,int> top = *occ.begin();
        occ.erase(occ.begin());
        
        int u = top.first;
        int v = top.second;
        if (done[u] || done[v])
            continue;
        done[u]=done[v]=true;
        
        
        while(u > 0 && done[u])
            u--;
        while(v < L-1 && done[v])
            v++;
        
        if (!done[u] && !done[v] && S[u]=='S' && S[v]=='T') {
            occ.insert(make_pair(u,v));
        }
        
        
    }
    
    
    int ans = 0;
    for(int i=0;i<L;i++)
        ans += (int)(!done[i]);
    
    cout << ans << endl;
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


vector<int>vab;
vector<int>vba;
string s[3]={"Sunny","Cloudy","Rainy"};
int main()
{
    string p;
    cin>>p;
    if(p=="Sunny")
    cout<<"Cloudy"<<endl;
    if(p=="Cloudy")
    cout<<"Rainy"<<endl;
    if(p=="Rainy")
    cout<<"Sunny"<<endl;
    return 0;
}
/*
10
16 7
15 15
12 14
2 5
3 9
1 10
14 14
4 6
*/


Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int s, w;
  cin >> s >> w;
  if (w >= s)
    cout << "unsafe" << endl;

  else
    cout << "safe" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;

int n,a[21][21];

int f(int mask,int i,vec(vec(int)) &dp)
{
	if(i<0) return 1;
	if(mask==0) return 0;
	if(dp[mask][i]!=-1) return dp[mask][i];
	dp[mask][i] = 0;
	loop(j,0,n) 
		if(a[i][j]==1 && (mask & (1<<j))>0) dp[mask][i] = (dp[mask][i] + f(mask - (1<<j),i-1,dp))%mod;
	return dp[mask][i]%mod;
}

signed main()
{
	fastio(0);
	cin>>n;
	vec(vec(int)) dp(1<<n, vec(int) (n,-1));
	loop(i,0,n) loop(j,0,n) cin>>a[i][j];
	cout<<f((1<<n)-1,n-1,dp)<<endl;
	return 0;		
}

Measured memory_bytes: 409856
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {

	double r;
	cin >> r;
	printf("%6lf %6lf\n", r*r*M_PI,2* r*M_PI);

	return 0;

}

Measured memory_bytes: 3248