akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  int N; cin >> N;
  char C[N][N];
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      cin >> C[i][j];
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++){
    char C2[N][N];
    for (int j = 0; j < N; j++){
      for (int k = 0; k < N; k++){
        if (i + j < N) C2[j][k] = C[i + j][k];
        else C2[j][k] = C[i + j - N][k];
      }
    }

    bool flag = true;

    for (int j = 0; j < N; j++){
      for (int k = 0; k < N; k++){
        if (C2[j][k] != C2[k][j]) flag = false;
      }
    }
    
    if (flag == true) ans++;
  }
  cout << ans * N << endl;

  return 0;
}

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

using namespace std;

#define ll long long
#define mx 0
#define mn 1e9
#define v(dt) vector<dt>
#define pr(x, y) pair<x,y>
#define loop(x, s, n) for(int x = s; x < n; ++x)
#define in_arr(n) loop(i,0,n){cin>>a[i];}
#define out_arr(n) loop(i,0,n){cout<<a[i];}

const int N = 1e5 + 7;

inline void boost() {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
}

//int a[N];

int main() {
    boost();
    ll n;
    cin >> n;
    ll input;
    vector<pair<ll, ll>> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> input;
        a[i] = make_pair(input, (i + 1));
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cout << a[i].second << " ";
    }
}

Measured memory_bytes: 2432
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else if (S == "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 256
def main():
    k, q = map(int, input().split())
    d = list(map(int, input().split()))
    nxm = [list(map(int, input().split())) for _ in [0]*q]
    for n, x, m in nxm:
        d2 = sum([(i-1) % m+1 for i in d[:(n-2) % k+1]])
        d3 = sum([(i-1) % m+1 for i in d[(n-2) % k+1:]])
        print(n-1-(x % m+(d2+d3)*((n-2)//k)+d2)//m)


main()


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

int main() {
  int X;
  cin >> X;
  int a = X/100;
  int ans = 0;
  for (int i = 100*a; i < 105*a+1; i++) {
    if (i == X) {
      ans = 1;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N,K,i;
	int count=0;
	scanf("%d%d",&N,&K);
	int tall[N];
	for(i=0;i<N;i++){
		scanf("%d",&tall[i]);
		if(tall[i]>=K){
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N;
  string a, b, c;
  cin >> N >> a >> b >> c ;

  int ans = 0;

  for (int i = 0; i < N; ++i) {
    unordered_set<char> U({a[i], b[i], c[i]});
    ans += U.size() - 1;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
ll sum[2][maxn];
int a[maxn];
void solve(){
	int n;scd(n);
	rep1(i,n)scd(a[i]);
	ll ans=0;
	for(int i=n-1-(n&1);i>=1;i-=2){
		ans+=1ll*a[i];
		sum[0][i]=sum[0][i+2]+a[i+1]-a[i];
		if(n&1)sum[1][i]=sum[1][i+2]+a[i+2]-a[i+1];
	}
	if(n&1){
		ll mx=0,mark=0;
		for(int i=n-1-(n&1);i>=1;i-=2){
			mx=max(mx,sum[1][i]);
			mark=max(mark,sum[0][i]+mx);
		}
		ans+=mark;
	}
	else {
		ll mx=0;
		for(int i=1;i<=n;i+=2)
			mx=max(mx,sum[0][i]);
		ans+=mx;
	}
	ac;
}
int main(){
    //IOS;
    //freopen("fenwick.in","r",stdin);
    //freopen("fenwick.out","w",stdout);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 7116
N = int(input())
A = [int(_) for _ in input().split()]

odd = []
even = []
for n in range(N):
    if n % 2 == 0:
        even.append(A[n])
    if n % 2 == 1:
        odd.append(A[n])

oppodd = odd[::-1]
oppeven = even[::-1]
#print(*oppeven)
#print(*oppodd)
if N % 2 != 0:
    B = oppeven + odd
    print(*B)
else:
    B = oppodd + even
    print(*B)
#n-1番目は1番目にくる
#n-2番目はn-1番目にくる
#n-3番目は2番目
#n-4番目は3

Measured memory_bytes: 26180
# ABC141c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

sanka = [0]*n

for i in a:
    sanka[i-1] += 1
# print(sanka)

for i in sanka:
    print('Yes' if i+k-q > 0 else 'No')

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

import sys

for line in sys.stdin:
    A = []
    A.append(float(line))
    sum = 0.0
    for i in range(1, 10):
        if i % 2:
            A.append(A[i-1]*2)
        else:
            A.append(A[i-1]/3)
    for i in range(10):
        sum += A[i]
    print sum

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

int main() {
  int n;
  string s;
  int q;
  cin >> n>>s>>q;
  vector<vector<int>>d(n+1,vector<int>(26));
  rep(i,n){
    d[i+1][s[i]-'a']++;
  }
  rep(i,n){
    rep(j,26){
      d[i+1][j]+=d[i][j];
    }
  }
  vector<int>p[26];
  vector<int>m[26];
  rep(i,q){
    int a;
    cin>>a;
    if(a==1){
      int b;
      char c;
      cin>>b>>c;
      m[s[b-1]-'a'].push_back(b);
      p[c-'a'].push_back(b);
      s[b-1]=c;
    }
    else{
      int b,c;
      cin>>b>>c;
      int now=0;
      rep(j,26){
        int co=0;
        rep(k,m[j].size()){
          if(m[j][k]>=b&&m[j][k]<=c){
            co--;
          }
        }
        rep(k,p[j].size()){
          if(p[j][k]>=b&&p[j][k]<=c){
            co++;
          }
        }
        if(co+d[c][j]-d[b-1][j]>0){
          now++;
        }
      }
      cout<<now<<endl;
    }
  }
}

Measured memory_bytes: 70484
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        solve();
    }

    void solve() {
        System.out.println(n * (n + 1) / 2);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 19284
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	k := nextInt()
	l := make([]int, 100+1)

	for i := 1; i <= 100; i++ {
		if a%i == 0 && b%i == 0 {
			l[i] = i
		}
	}
	sort.Ints(l)

	fmt.Println(l[101-k])

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
from collections import Counter
N = int(input())
Ass = [list(map(int, input().split())) for _ in range(N)]
ct = Counter()
q = set([(i, 0) for i in range(N)])
idxs = [0] * N
n = 0
ans = 0
while q:
  nq = set()
  for i, k in q:
    a = i+1
    b = Ass[i][k]
    if a > b: a, b = b, a
    ct[(a, b)] += 1
    if ct[(a, b)] == 2:
      n += 1
      idxs[a-1] += 1
      if idxs[a-1] < N-1:
        nq.add((a-1, idxs[a-1]))
      idxs[b-1] += 1
      if idxs[b-1] < N-1:
        nq.add((b-1, idxs[b-1]))
  ans += 1
  q = nq
if n == N * (N-1) // 2:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 130268
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

int n, m, s, g;

double solve(pair<double, double> r[31][31])
{
    double result[31][31][31];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= 31; k++){
                result[i][j][k] = mod;
            }
        }
    }
    priority_queue<pair<double, pair<pair<int, int>, int> > > qu;
    qu.push(make_pair(0.0, make_pair(make_pair(s, -1), 0.0)));
    while(!qu.empty()){
        double nowcost = (qu.top()).first;
        pair<int, int> nowandbefore = ((qu.top()).second).first;
        int nowv = ((qu.top()).second).second;
        int nowp = nowandbefore.first;
        int beforep = nowandbefore.second;
        // cout << nowp << " " << beforep << " " << -nowcost << " " << nowv << endl;
        qu.pop();
        if(nowp == g && nowv == 1) {
            return -nowcost;
        }
        if(beforep != -1 && result[nowp][beforep][nowv] <= -nowcost) continue;
        result[nowp][beforep][nowv] = -nowcost;
        for(int i = 1; i <= n; i++){
            if(r[nowp][i].first == 0 || i == beforep) continue;
            double kyori = r[nowp][i].first;
            double limit = r[nowp][i].second;
            double nextcost;
            for(int j = -1; j <= 1; j++){
                if(nowv + j <= 0) continue;
                nextcost = nowcost - (double)kyori / (nowv + j);
                if(nowv + j <= limit && -nextcost < result[i][nowp][nowv + j]){
                    qu.push(make_pair(nextcost, make_pair(make_pair(i, nowp), nowv + j)));
                }
            }
        }
    }
    return -1;
}

int main()
{
    while(1){
        cin >> n >> m;
        if(n == 0) break;
        cin >> s >> g;
        pair<double, double> road[31][31];
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                road[i][j] = make_pair(0, 0);
            }
        }
        for(int i = 0; i < m; i++){
            int x, y;
            double d, c;
            cin >> x >> y >> d >> c;
            road[x][y] = road[y][x] = make_pair(d, c);
        }
        double ans =  solve(road);
        if(ans == -1) cout << "unreachable" << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 15572
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

string s;
ll k;
ll ans;

ll f(ll p, ll q)
{
    if(q == 0) return 1;
    if(p >= s.size()) return 0;
    if(s[p] == '0') return f(p + 1, q);
    ll re = 0;
    re += f(p + 1, q - 1);
    ll x = 1;
    for(ll i = 0; i < q; i++) x *= 9;
    ll lt = s.size() - p - 1;
    if(q == 1) re += lt * x + (s[p] - '1') * x / 9;
    else if(q == 2) re += lt * (lt - 1) / 2 * x + (s[p] - '1') * lt * x / 9;
    else re += lt * (lt - 1) * (lt - 2) / 6 * x + (s[p] - '1') * lt * (lt - 1) / 2 * x / 9;
    return re;
}

int main()
{
    cin>>s>>k;
    cout<<f(0, k);
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(long[]);
    auto N = nm[0];
    auto M = nm[1];
    auto as = readln.split.to!(long[]);
    auto x = as[0]/2;
    int k;
    while (x % 2 == 0) {
        ++k;
        x /= 2;
    }
    x = as[0]/2;
    foreach (a; as[1..$]) {
        a /= 2;
        x = x * a / gcd(x, a);
        if (x <= 0) {
            writeln(0);
            return;
        }
        int kk;
        while (a%2 == 0) {
            ++kk;
            a /= 2;
        } 
        if (k != kk) {
            writeln(0);
            return;
        }
    }
    writeln((M/x+1)/2);
}

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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep (i, n)
    {
        cin >> c[i];
        rep (j, m)
            cin >> a[i][j];
    }

    int ans = INF;
    rep (bit, 1 << n)
    {
        int cost = 0;
        vector<int> proficiency(m, 0);
        rep (i, n)
            if (bit & 1 << i)
            {
                cost += c[i];
                rep (j, m)
                    proficiency[j] += a[i][j];
            }

        bool ok = true;
        rep (i, m)
            if (proficiency[i] < x)
                ok = false;
        if (ok)
            ans = min(cost, ans);
    }

    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
long long a[1000001],f[1000001],d[1000001];
int main()
{
	long long n,t,k=0,g=0;
	cin>>n>>t;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	f[0]=a[1];
	for(int i=1;i<=n;i++)
		f[i]=min(f[i-1],a[i]);
	for(int i=1;i<=n;i++)
		d[i]=a[i]-f[i];
	for(int i=1;i<=n;i++)
		if(d[i]>k)
			k=d[i];
	for(int i=1;i<=n;i++)
		if(d[i]==k)
			g++;
	cout<<g<<endl;
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	int S=0;
	for (int i=0; i<N; i++) {
		int A;
		cin >>A;
		S +=A;
		S %=2;
	}
	if (0==S)
		cout <<"YES" <<endl;
	else
		cout <<"NO" <<endl;
	return 0;
}



Measured memory_bytes: 256
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;


int main() {
#ifdef HIRO
  ifstream cin("input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif

  int n, k, r, s, p;
  ll res = 0;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  vector<int> scores(n);
  for(int i = 0; i < n; i++) {
    int score;
    switch(t[i]) {
      case 'r':
        score = p;
        break;
      case 's':
        score = r;
        break;
      case 'p':
        score = s;
        break;
    }
    if(i - k >= 0 && scores[i - k] != 0 && t[i] == t[i - k]) {
      score = 0;
    }
    scores[i] = score;
    res += (ll)score;
  }
  cout << res;
  return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}


int main(){
    ll h,w;
    cin >> h >> w;
    if(h==1 || w==1){
        cout << 1 << endl;
    }
    else {
        if(h%2==0) cout <<(h/2)*w << endl;
        else {
            if(w%2==0){
                cout << h*w/2 << endl;
            }
            else {
                cout << (h/2+1)*(w/2+1)+(h/2)*(w/2) << endl;
            }
        }
    }
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ll K; cin>>K;
  vector<ll> A(K); rep(i,K) cin>>A[i];
  //vector<ll> A(100000,1000000000);
  
  vector<ll> up(K+1,2),down(K+1,2);
  if(A[K-1]!=2) {cout<<-1<<endl; return 0;}
  for(int i=K-1;i>=0;i--){
    up[i]=up[i+1]+(A[i]-1); if(i!=0) up[i]=up[i]/A[i-1]*A[i-1];
    down[i]=down[i+1]; if(i!=0&&down[i]%A[i-1]!=0) down[i]=(down[i]/A[i-1]+1)*A[i-1];
    
    if(up[i]<down[i]) {cout<<-1<<endl; return 0;}
  }
  
  cout<<down[0]<<" "<<up[0]<<endl;
    
  return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#define M std::cin>>
int s[200000],n,c,l,z,x,i,h=1e9+7;main(){M n>>z;c=l=s[z]=1;for(i=1;i<n;i++){M x;if(x!=z)c=(c+s[x])%h,s[x]=(s[x]+l)%h;l=c,z=x;}std::cout<<c;}
                                                                                                       

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
    int x, i, j, t;
    x = A[r];
    i = p-1;
    for(j=p; j<r; j++){
        if(A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;
    return i+1;
}


int main(){
    int q;
    cin >> n;
    for(int i=0; i<n; i++) cin >> A[i];
    
    q = partition(0, n-1);
    
    for(int i=0; i<n; i++){
        if(i) cout << " ";
        if(i==q) cout << "[";
        cout << A[i];
        if(i==q) cout << "]";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3448
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
//		int w = Integer.parseInt(sa[1]);
		int n = Integer.parseInt(sa[2]);
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.x = Integer.parseInt(sa[0]);
			o.y = Integer.parseInt(sa[1]);
			o.z = o.y - o.x;
			arr[i] = o;
		}
		br.close();

		Arrays.sort(arr, (o1, o2) -> {
			if (o1.y != o2.y) {
				return o1.y - o2.y;
			}
			return o1.x - o2.x;
		});

		int ans = h;
		TreeMap<Integer, Integer> map = new TreeMap<>();
		map.put(1, 0);
		for (Obj o : arr) {
			if (o.x > ans) {
				continue;
			}
			int val = map.floorEntry(o.x).getValue();
			if (o.z < val) {
				ans = o.x - 1;
			} else {
				map.put(o.x, Math.min(val, o.z - 1));
			}
		}
		System.out.println(ans);
	}

	static class Obj {
		int x, y, z;
	}
}


Measured memory_bytes: 81764
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();
        int[] x = new int[n+1];
        for(int i = 0; i < n; i++){
            if(s.charAt(i) == 'E'){
                x[i+1] = x[i] + 1;
            }else {
                x[i+1] = x[i];
            }
        }
        int ans = n;
        for(int i = 1; i < n+1; i++){
            //System.out.print(x[i]);
            ans = Math.min(ans,(i-1) - x[i-1] + x[n] - x[i]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 30840
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n;
    cin >> n;
    int a;
    bool ok = true;
    rep(i,n){
        cin >> a;
        if(a % 2 == 0){
            if(a % 3 !=0 && a % 5 != 0){
                ok = false;
            }
        }
    }
    if(ok){
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string>

using namespace std;

int solve(const vector<string>& vs, int sx, int sy){
    int W = vs[0].size();
    int H = vs.size();
    vector<vector<int>> step(H, vector<int>(W, 1000000));
    step[sx][sy] = 0;
    queue<pair<int,int>> qu; qu.emplace(sx, sy);
    int res = 0;
    while(!qu.empty()){
        auto p = qu.front(); qu.pop();
        int dx[] = {-1, 0, 1, 0};
        int dy[] = {0, -1, 0, 1};
        for(int i=0;i<4;i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(nx < 0 || H <= nx || ny < 0 || W <= ny || vs[nx][ny] == '#') continue;
            int ns = step[p.first][p.second] + 1;
            if(ns < step[nx][ny]){
                step[nx][ny] = ns;
                qu.emplace(nx, ny);
                res = max(res, ns);
            }
        }
    }
    return res;
}

int main(){
    int H, W;
    while(cin >> H >> W){
        vector<string> vs(H);
        for(auto& s : vs) cin >> s;
        int res = 0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(vs[i][j] == '#') continue;
                res = max(res, solve(vs, i, j));
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	double a,b;
	cin>>a>>b;
	int d=a/b;
	int r=a-d*b;
	double f=a/b;
	printf("%d %d %7.5f",d,r,f);
			return 0;
}

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

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

  string ans = "";
  while (N != 0) {
    if (N % 2 != 0) {
      N--;
      ans += "1";
    }
    else ans += "0";
    N /= -2;
  }
  if (ans == "") ans = "0";
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 256
mat=[list(map(int,input().split())) for i in range(3)]
N=int(input())
c=0
for n in range(N):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if mat[i][j]==b:
        mat[i][j]=0
for i in range(3):
  if mat[i][0]==0 and mat[i][1]==0 and mat[i][2]==0:
    c+=1
  elif mat[0][i]==0 and mat[1][i]==0 and mat[2][i]==0:
    c+=1
  elif mat[0][0]==0 and mat[1][1]==0 and mat[2][2]==0:
    c+=1
  elif mat[0][2]==0 and mat[1][1]==0 and mat[2][0]==0:
    c+=1

if c >= 1:
  print("Yes")
else:
  print("No")
      

       

Measured memory_bytes: 38256
a = list(input())

dp = [[0]*3 for i in range(len(a)+1)]

ppp = 1
for i in range(len(a))[::-1]:
	if a[i] == "A":
		dp[i][0] += dp[i+1][0] + dp[i+1][1]
		dp[i][1] += dp[i+1][1]
		dp[i][2] += dp[i+1][2]
	elif a[i] == "B":
		dp[i][0] += dp[i+1][0]
		dp[i][1] += dp[i+1][1] + dp[i+1][2]
		dp[i][2] += dp[i+1][2]
	elif a[i] == "C":
		dp[i][0] += dp[i+1][0]
		dp[i][1] += dp[i+1][1]
		dp[i][2] += dp[i+1][2] + ppp
	else:
		dp[i][0] += 3 * dp[i+1][0] + dp[i+1][1]
		dp[i][1] += 3 * dp[i+1][1] + dp[i+1][2]
		dp[i][2] += 3 * dp[i+1][2] + ppp
		ppp *= 3
		ppp %= 10**9+7
	for j in range(3):
		dp[i][j] %= (10**9 + 7)
print(dp[0][0] % (10**9 + 7))

Measured memory_bytes: 23572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    vector<ll> X(N,0);
    vector<ll> Y(N,0);
    for(ll i=0;i<N;i++){
        cin>>X[i]>>Y[i]
    ;}  
    ll ans=0;
    for(ll i=0;i<N;i++){
       for(ll j=0;j<N;j++){
           if(i==j)continue;
           ll p=X[i]-X[j];
           ll q=Y[i]-Y[j];
           ll count=0;
           for(ll k=0;k<N;k++){
              for(ll l=0;l<N;l++){
                  if(X[k]-X[l]==p&&Y[k]-Y[l]==q)count++;
              ;}
           ;}
           chmax(ans,count);
       ;}
    ;}
    print(N-ans)

    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,k,sum=0;
	cin >> n >> k;
	vll h(n);
	rep(i,n){
		cin >> h[i];
		sum+=h[i];
	}
	if(k>=n){
		cout << 0 << endl;
	}
	else{
		sort(rall(h));
		rep(i,k){
			sum-=h[i];
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    vs v{"SUN","MON","TUE","WED","THU","FRI","SAT","SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin>>s;
    for(int i=0;i<7;i++){
        if(s==v[i]){
            for(int j=i+1;j<14;j++){
                if(v[j]=="SUN"){
                    fin(j-i);
                    return 0;
                }
            }
        }
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    ll l, r; cin >> l >> r;
    ll ans = INF;
    bool flag = false;
    FOR(i, l, r){
        FOR(j, i + 1, r + 1){
            ans = min(ans, (i * j) % 2019);
            if(ans == 0){
                flag = true;
                break;
            }
        }
        if(flag) break;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;
typedef pair<int,int> P;
 
 
 
int main()
{
  string s,S;
  cin>>s;
  int a[60];
  int d=0;
  bool flag=true;
  for(int i=0;i<s.size();i++){
    if(s[i]=='K'&&i<=1)d=1;
    if(d==1)S+=s[i];
    if(s[i]=='R'){
      if((s.size()-1-i)>1){
	cout<<"NO"<<endl;
	return 0;
      }
      break;
    }
  }
 
  if(S=="KIHBR"||S=="KIHABAR"||S=="KIHBAR"||S=="KIHABR")cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

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

int main(){
    int n;
    
    while(cin>>n){
    int count=0;
    for(int i=0;i<10; i++){
        for(int s=0;s<10; s++){
            for(int t=0;t<10; t++){
                for(int w=0;w<10; w++){
                    if(i+s+t+w==n)count++;
                }
            }
        }
    }
        cout<<count<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main(void) {
    int n, k;
    cin >> n >> k;

    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];

    sort(p.begin(), p.end());

    int ans = 0;
    rep(i, 0, k) ans += p[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
n = int(input())
k = int(input())
x = int(input())
y = int(input())
a = 0
b = 0
c = 0
e = 0

if n <= k:
    a = n * x
else:
    c = n - k
    a = x * k
    b = c * y

e = a + b
print(e)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

vector<ll> L(87);
int main() {
  int N;
  cin >> N;
  L.at(0) = 2;
  L.at(1) = 1;
  for(int i=2; i<=86; i++) {
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
inline ll mod(ll x) { return x%MOD; }
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	vector<ll> ans(k+1);
	ll sum = 0;
	for(ll i=k;i>=1;--i)
	{
		ll co = 0;
		for(ll j=i;j<=k;j+=i) co++;
		ans[i] = power(co,n,MOD);
		for(ll j=2*i;j<=k;j+=i) ans[i] = mod(ans[i] - ans[j] + MOD);
		sum = mod(mod(sum) + mod(mod(ans[i]) * mod(i)));
	}
	cout<<sum<<endl;
	
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
//#include<cmath>
#define maxn 55
const double eps =1e-10;
const double g =9.8;
using namespace std;

int N,V,X,Y;
int L[maxn],B[maxn],R[maxn],T[maxn];

int dcmp(double d){
	if(d<-eps) return -1;
	else if(d>eps) return 1;
	else return 0;
}

double cal(double vy,double t){
	return vy*t-0.5*g*t*t;
}

int cmp(double lb,double ub,double a){
	return a-lb<-eps?-1:(ub-a<(eps)?1:0);
}

bool check(double qx,double qy){
	double a=0.25*g*g,b=g*qy-V*V,c=1.0*qx*qx+qy*qy;
	double D=b*b-4*a*c;
	if(dcmp(D)==0) D=0;
	if(D<0) return false;
	for(int d=-1;d<=1;d+=2){
		double t2=(-b+d*sqrt(D))/2/a;
		if(t2<=0) continue;
		double t=sqrt(t2);
		
		double vx=qx/t,vy=(qy+0.5*g*t*t)/t;
		double yt=cal(vy,X/vx);
		if(dcmp(yt-Y)<0) continue;
		
		bool ok=true;
		for(int i=0;i<N;i++){
			if(L[i]>=X) continue;
			if(R[i]==X&&Y<=T[i]&&B[i]<=yt) ok=false;
			
			int yL=cmp(B[i],T[i],cal(vy,L[i]/vx)),
		     	yR=cmp(B[i],T[i],cal(vy,R[i]/vx)),
		     	xH=cmp(L[i],R[i],vx*(vy/g)),
		     	yH=cmp(B[i],T[i],cal(vy,vy/g));
		    if(xH==0&&yH>=0&&yL<0) ok=false;
		    if(yL*yR<=0) ok=false;
		}
		if(ok) return true;
	}
	return false;
}

void slove(){
	for(int i=0;i<N;i++)
		R[i]=min(X,R[i]);
	bool ok=check(X,Y);
	for(int i=0;i<N;i++){
		ok|=check(L[i],T[i]);
		ok|=check(R[i],T[i]);
	}
	printf("%s\n",ok?"Yes":"No");
}

void MAIN()
{
	scanf("%d%d%d%d",&N,&V,&X,&Y);
	for(int i=0;i<N;i++) scanf("%d%d%d%d",&L[i],&B[i],&R[i],&T[i]);
	slove();
}

int main()
{
//	freopen("in#pro.txt","r",stdin);
//	freopen("out#pro.txt","w",stdout);
	MAIN();
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define EPS 1e-9
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

#define EQ(n,m) (abs((n)-(m)) < EPS)

namespace std {
  bool operator<(const Point a, const Point b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecSS(Point a1, Point a2, Point b1, Point b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
  ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
  double d1 = cross(b2-b1, b1-a1);
  double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  assert(!EQ(d2, 0)); // ???????????????
  return a1 + d1/d2 * (a2-a1);
}

int main(void){
    int N;
    cin>>N;
    while(N--){
        vector<pair<Point,bool>> cross;
        double ax,ay,bx,by,sx,sy,tx,ty;
        int n,o,l;
        cin>>ax>>ay>>bx>>by>>n;
        Point a={ax,ay},b={bx,by};
        rep(i,n){
            cin>>sx>>sy>>tx>>ty>>o>>l;
            Point s={sx,sy},t={tx,ty};
            if(isecSS(a,b,s,t)){
                cross.push_back({crosspointLL(a,b,s,t),o==l});
            }
        }

        sort(all(cross));
        int cnt=0;
        rep(i,(int)cross.size()-1){
            cnt += (cross[i].second!=cross[i+1].second);
        }
        cout<<cnt<<endl;
    }

    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> x(n), v(n);
  rep(i, 0, n) cin >> x[i];
  v = x;
  sort(v.begin(), v.end());
  int l = v[n / 2 - 1];
  int r = v[n / 2];

  rep(i, 0, n) {
    if (x[i] < r)
      cout << r << endl;
    else
      cout << l << endl;
  }
}


Measured memory_bytes: 3840
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
struct edge {int cost; ll value;}; 
int N, W;
edge L[103];
ll DP[103][100005]; //日にち, i日目までで使った重さ, i日目までの幸福度の最大値

ll dfs(int idx, int w){
  if (idx==N) return 0;
  if (w==0) return 0;
  if (DP[idx][w] > 0) return DP[idx][w];
  edge e = L[idx];
  ll v1 = dfs(idx+1, w);
  if (w < e.cost) {
    DP[idx][w] = v1;
    return v1;
  }
  ll v2 = dfs(idx+1, w-e.cost) + e.value;
  if (v1 > v2) {
    DP[idx][w] = v1;
    return v1;
  }
  DP[idx][w] = v2; 
  return v2;
}

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

  cin >> N >> W;
  int w; 
  ll v;
  rep(i, N) {
    cin >> w >> v;
    edge e = {w, v};
    L[i] = e;
  }

  DP[0][0] = 0;
  ll ans = dfs(0, W);
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 78080
#include <iostream>
#include <vector>

using namespace std;

int W, H;
int C[50][50];

void DFS(int h, int w)
{
    if (w < 0 || w >= W) return;
    if (h < 0 || h >= H) return;
    if (C[h][w] == 0) return;
    C[h][w] = 0;

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

    for (int i = 0; i < 8; ++i) {
        DFS(h+dx[i], w+dy[i]);
    }
}

int main()
{
    while (1) {
        cin >> W >> H;
        if (W == 0 && H == 0) {
            break;
        }

        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                cin >> C[h][w];
            }
        }

        int Res = 0;
        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                if (C[h][w] == 1) {
                    DFS(h, w);
                    ++Res;
                }
            }
        }
        cout << Res << endl;
    }

    return 0;
}


Measured memory_bytes: 3332
#include <stdio.h>
#define MAX 36

typedef struct{
  char suit;
  int value;
}card;

void BubbleSort(card *,int);
void SelectionSort(card *,int);

int main(){
  int i,j,n,judge=0;
  card C[MAX],C1[MAX],C2[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%c",&C[i].suit);
    scanf("%c",&C[i].suit);
    scanf("%d",&C[i].value);

    C1[i] = C[i];
    C2[i] = C[i];
  }

  
  BubbleSort(C1,n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%c",C1[i].suit);
    printf("%d",C1[i].value);
  }
  printf("\nStable\n");

  SelectionSort(C2,n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%c",C2[i].suit);
    printf("%d",C2[i].value);
    if(C1[i].suit != C2[i].suit)judge = 1;
  }
  if(judge)printf("\nNot stable\n");
  else printf("\nStable\n");
  
  
  
  
  return 0;
}

void BubbleSort(card *C,int n){
  int i,j;
  card tmp;
  for(i=0;i<n;i++){
    for(j = n-1;j>i;j--){
      if(C[j].value < C[j-1].value){
	tmp = C[j];
	C[j] = C[j-1];
	C[j-1] = tmp;
      }
    }
  }
}

void SelectionSort(card *C,int n){
  int i,j,minj;
  card tmp;
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(C[j].value < C[minj].value){
	minj = j;
      }
    }
    tmp = C[i];
    C[i] = C[minj];
    C[minj] = tmp;
  }
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n ){
	std::ostringstream stm ;
	stm << n ;
	return stm.str() ;
}


int main(void){
	int r,c;
	cin >> r >> c;
	int t[r+1][c+1];
	for(int i = 0; i < r; i++){
		int tmp = 0;
		for(int j = 0; j < c; j++){
			cin >> t[i][j];
			tmp += t[i][j];
		}
		t[i][c] = tmp;
	}
	for(int i = 0; i <= c; i++){
		int tmp = 0;
		for(int j = 0; j < r; j++){
			tmp += t[j][i];
		}	
		t[r][i] = tmp;
	}
	for(int i = 0; i <= r; i++){
		for(int j = 0; j <= c; j++){
			cout << t[i][j];
			if(j == c)cout << "\n";
			else cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 3128
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        g.append(list(map(int, input().split())))
    for i in range(h):
        k = list(map(int, input().split()))
        for j in range(w):
            g[i][j] = abs(g[i][j] - k[j])

    m = (h + w) * 40

    if m == 0:
        print(0)
        exit()

    dp = [[False] * m for _ in range(w)]
    dp[0][g[0][0]] = True
    for j in range(1, w):
        for k in range(m):
            if dp[j-1][k]:
                dp[j][abs(k - g[0][j])] = True
                try:
                    dp[j][k + g[0][j]] = True
                except:
                    pass
    
    for i in range(1, h):
        new_dp = [[False] * m for _ in range(w)]
        for k in range(m):
            if dp[0][k]:
                new_dp[0][abs(k - g[i][0])] = True
                try:
                    new_dp[0][k + g[i][0]] = True
                except:
                    pass
        
        for j in range(1, w):
            for k in range(m):
                if new_dp[j-1][k] or dp[j][k]:
                    new_dp[j][abs(k - g[i][j])] = True
                    try:
                        new_dp[j][k + g[i][j]] = True
                    except:
                        pass
        dp = new_dp

    for j in range(m):
        if dp[w-1][j]:
            print(j)
            break

main()

Measured memory_bytes: 222088
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int a,b,c;
        int ans=0;
        scanf("%d %d %d",&a,&b,&c);
        for(int i=a;i<=b;i++){
                if(c%i==0){
                        ans+=1;
                }
        }
        printf("%d\n",ans);
        return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <string.h>

int main(){
    char s[100][11], t[100][11];
    int N, M, count, answer = 0;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%s", s[i]);
    }
    scanf("%d", &M);
    for(int i = 0; i < M; i++){
        scanf("%s", t[i]);
    }

    for(int i = 0; i < N; i++){
        count = 0;
        for(int j = 0; j < N; j++){
            count += (strcmp(s[i], s[j]) == 0);
        }
        for(int j = 0; j < M; j++){
            count -= (strcmp(s[i], t[j]) == 0);
        }
        answer = ((count > answer) ? count : answer);
    }

    printf("%d\n", answer);
    return 0;
}

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

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int main() {
  string s;
  cin >> s;
  cout << 700 + 100 * stringcount(s, 'o') << endl;
  return 0;
}

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

int  main()
{
	long n, m;
	cin >> n >> m;

	set<long> st;
	map<long, long> mp;
	long wa = 0;
	rep(i, m)
	{
		long p; string s;
		cin >> p >> s;
		if (s == "AC")
			st.insert(p);
		if (s == "WA")
		{
			if (!st.count(p))
				mp[p]++;
		}
	}
	rep1(i, n)
	{
		if(st.count(i))
			wa += mp[i];
	}
	long ac = st.size();
	cout << ac << " " << wa << endl;
	return (0);
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();

		String result = "Impossible";
		if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) {
			result = "Possible";
		}
		System.out.println(result);

	}

}

Measured memory_bytes: 23124