akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

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

            ArrayList<Integer> res = new ArrayList<>();
            int count0 = 0;
            int count1 = 0;
            for (int i = 0; i < S.length(); i++) {
                char c = S.charAt(i);
                if (c == '(') {
                    count0++;
                    res.add(0);
                } else if (c == ')') {
                    count1++;
                    res.add(1);
                    if (count1 > count0) {
                        count0++;
                        res.add(0, 0);
                    }
                }
            }
            while (count1 < count0) {
                count1++;
                res.add(1);
            }

            StringBuilder valid = new StringBuilder();
            for (Integer integer : res) {
                valid.append(integer.intValue() == 0 ? '(' : ')');
            }

            System.out.println(valid.toString());
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define N 303
#define P 1000000007
using namespace std;
int n,m,l[N],x[N],f[N][N][N],g[N][N][N],h[N][N];
vector <int> v[N];
bool vaild(int r,int R,int G,int B){
    for(int i:v[r])
        if((R>=l[i])+(G>=l[i])+(B>=l[i])!=x[i])return 0;
    return 1;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1,r;i<=m;++i){
        scanf("%d%d%d",&l[i],&r,&x[i]);
        v[r].push_back(i);
    }
    int ans=0;
    f[0][0][0]=g[0][0][0]=1;
    for(int i=1;i<=n;++i){
        for(int j=0;j<i;++j)
            for(int k=0;!k || k<j;++k){
                if(!vaild(i,i,j,k))continue;
                if(j<i-1)f[i][j][k]=f[i-1][j][k];
                else if(!j)f[i][j][k]=3;
                else if(!k){
                    f[i][j][k]=f[i-1][0][0]+g[i-1][j-1][0];
                    if(f[i][j][k]>=P)f[i][j][k]-=P;
                }
                else{
                    f[i][j][k]=g[i-1][j-1][k]-g[i-1][k][k]+P;
                    if(f[i][j][k]>=P)f[i][j][k]-=P;
                    f[i][j][k]+=h[i-1][k];
                    if(f[i][j][k]>=P)f[i][j][k]-=P;
                }
                if(i==n){
                    ans+=f[i][j][k];
                    if(ans>=P)ans-=P;
                }
            }
        g[i][0][0]=f[i][0][0];
        for(int j=1;j<i;++j)
            for(int k=0;k<j;++k){
                g[i][j][k]=g[i][j-1][k]+f[i][j][k];
                if(g[i][j][k]>=P)g[i][j][k]-=P;
                h[i][j]+=f[i][j][k];
                if(h[i][j]>=P)h[i][j]-=P;
            }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 215680
#include <iostream>
using namespace std;
string a[8]={"hao","hao","xue","xi","tian","tian","xiang","shang"};
int main() {
	ios::sync_with_stdio(false);
	for(int i=1;i<10;i++)
		for(int j=1;j<10;j++)
			cout<<i<<"x"<<j<<"="<<i*j<<endl;
	return 0;
}

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

int bubbleSort(int A[], int N) {

	int count=0, flag,j,i=0;
	flag = 1;
	while (flag) {
		flag = 0;
		for (j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				count++;
				
			}
		}
		i++;
	}
	return count;
}
int main() {

	int A[100];
	int N, i, count;

	cin >> N;
	for (i = 0; i < N; i++)
		cin >> A[i];
	count = bubbleSort(A, N);

	cout << A[0];
	for (i = 1; i < N; i++) cout <<" "<< A[i];
	cout << endl;
	cout << count << endl;


}

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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int n, m, q;
int ans;
vector<int> Q[51];
vector<int> curr;

void genPerms() {
	if (size(curr) == n) {
		int val = 0;
		for (int i = 1; i <= q; i++) {
			if (curr[Q[i][1] - 1] - curr[Q[i][0] - 1] == Q[i][2]) {
				val += Q[i][3];
			}
		}
		ans = max(val, ans);
		return;
	}
	int start = 1;
	if (size(curr)) start = curr.back();
	for (int i = start; i <= m; i++) {
		curr.pb(i);
		genPerms();
		curr.pop_back();
	}
}

int32_t main() { fastio;
	cin >> n >> m >> q;
	int a, b, c, d;
	for (int i = 1; i <= q; i++) {
		cin >> a >> b >> c >> d;
		Q[i] = { a, b, c, d };
	}
	genPerms();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
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*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll N;cin>>N;
    for(int i=N;;i--){
        if((int)sqrt(i)*(int)sqrt(i)==i){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
from collections import deque


def bfs(start):
    Q = deque()
    Q.append(start)
    dist[start] = 0

    while Q:
        v = Q.popleft()

        for nv in G[v]:
            if dist[nv] != -1:
                continue

            # print(Q)
            dist[nv] = dist[v] + 1
            Q.append(nv)


N = int(input())

G = [[]] + [list(map(int, input().split())) for _ in range(N)]
for a in range(1, N + 1):
    b = G[a][2:]
    G[a] = b

# print(G)
dist = [-1 for _ in range(N + 1)]

start = 1
bfs(start)
# print(dist[1:])
for i in range(1, N + 1):
    print(i, dist[i])



Measured memory_bytes: 6036
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<ll> red(a);
    vector<ll> green(b);
    vector<ll> clear(c);

    rep(i, a)cin >> red[i];
    rep(i, b)cin >> green[i];
    rep(i, c)cin >> clear[i];

    sort(ALL(red), greater<ll>());
    sort(ALL(green), greater<ll>());

    vector<ll> ringo = clear;
    rep(i, x)ringo.push_back(red[i]);
    rep(i, y)ringo.push_back(green[i]);
    
    sort(ALL(ringo), greater<ll>());

    ll ans = 0;
    rep(i, x+y)ans += ringo[i];

    cout << ans << endl;
}

Measured memory_bytes: 7280
N, W = [int(i) for i in input().split()]
dp = [[0 for j in range(W + 1)] for i in range(N + 1)]
v = w = 0
for i in range(N - 1, -1, -1):
    v, w = [int(i) for i in input().split()]
    for j in range(0, W + 1):
        dp[i][j] = dp[i + 1][j]
        if j >= w :
            dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w] + v)
print(dp[0][W])

Measured memory_bytes: 27984
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
#include <stdlib.h>
#include <math.h> 
#include <iomanip>

#define PI 3.1415926535897932384626433832795028841971

using namespace std;

//int main(int argc, char *argv[]){
int main(void){

	int A=0, B=0;
	int H=0, M=0;
	
	cin >> A >> B >> H >> M;

	long double long_ang  = 6.0 * (long double)M;
	long double short_ang = 30.0 * (long double)H + 0.5 * (long double)M;

	long double x_pos = A * cos(long_ang * PI / 180.0) - B * cos(short_ang * PI / 180.0);
	long double y_pos = A * sin(long_ang * PI / 180.0) - B * sin(short_ang * PI / 180.0);

	long double v2 = x_pos * x_pos + y_pos * y_pos;
	long double v = sqrt(v2);

	//cout << v << endl;
	cout << fixed << setprecision(20) << v << endl;

}

Measured memory_bytes: 4172
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	rrep(i, s.size()-t.size()+1){
		string comp = s.substr(i, t.size());
		bool flag = true;
		rep(j, comp.size()){
			if(comp[j] != '?' && comp[j] != t[j]){
				flag = false;
				break;
			}
		}
		if(flag == true){
			rep(j, s.size()){
				if(j == i){
					cout << t;
					j += t.size()-1;
				}else{
					if(s[j] == '?'){
						cout << 'a';
					}else{
						cout << s[j];
					}
				}
			}
			cout << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int n, t, a;
	cin >> n >> t >> a;
	
	int h[n], ans;
	double tmp = 10000000;
	
	for (int i = 0; i < n; i++) {
	    cin >> h[i];
	    double ab = fabs(a - (t - h[i]*0.006));
	    if(tmp > ab){
	        ans = i + 1;
	        tmp = ab;
	    }
	}
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Online Judge: Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define EMPP emplace_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
const int N = 110000;
int mem[N + 5];
LL solv(LL n)
{
	if (n <= 0)
		return 0;
	if (mem[n] != -1)
		return mem[n];
	LL cur = n;
	for (LL i6 = 1; i6 <= n; i6 *= 6)
		cur = min(cur, solv(n - i6) + 1);
	for (LL i9 = 1; i9 <= n; i9 *= 9)
		cur = min(cur, solv(n - i9) + 1);
	return mem[n] = cur;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	memset(mem, -1, sizeof mem);
	LL n;
	cin >> n;
	LL ans = solv(n);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){

	int N;
	string S;

	cin >> N;

	int i = 0;

	for( ; i < N ; i++){
		
		cin >> S;
	
		if( S == "Y"){
		cout << "Four" << endl;
		break;
		}

	}

	if( i == N )
	cout << "Three" << endl;
}

Measured memory_bytes: 3544
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<cstdio>
using namespace std;
int n;
inline int read(){
	char ch=getchar();
	int x=0,f=1;
	while(ch<'0' || ch>'9')	{if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
    n=read();
    if(n%2){
    	n*=2;
	}
	printf("%d",n);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll H, W;
vector<string> S;
vector<vector<ll>> mv(1000, vector<ll>(1000, INF));
deque<pair<ll, ll>> det;

void bfs(ll x, ll y, ll d, bool w){
  if(x < 0 || x >= H || y < 0 || y >= W){
    return;
  }
  if(S.at(x).at(y) == '#'){
    return;
  }
  if(mv.at(x).at(y) <= d){
      return;
  }
  if(w){
      if(chmin(mv.at(x).at(y), d+1)){
        det.push_back(make_pair(x, y));
    }
  }
  else{
      if(chmin(mv.at(x).at(y), d)){
        det.push_front(make_pair(x, y));
    }
  }
}

int main()
{
    cin >> H >> W;
    ll Ch, Cw, Dh, Dw;
    cin >> Ch >> Cw >> Dh >> Dw;
    Ch--;
    Cw--;
    Dh--;
    Dw--;
    S.resize(H);
    rep(i, H){
        cin >> S.at(i);
    }
    bfs(Ch, Cw, 0, false);
    while(!det.empty()){
        pair<ll, ll> q = make_pair(det.front().first, det.front().second);
        det.pop_front();
        ll d = mv.at(q.first).at(q.second);
        bfs(q.first+1, q.second, d, false);
        bfs(q.first-1, q.second, d, false);
        bfs(q.first, q.second+1, d, false);
        bfs(q.first, q.second-1, d, false);
        if(q.first+1 < H){
            if(S.at(q.first+1).at(q.second) == '#'){
                rep2(i, 1, 3){
                    rep2(j, -2, 3){
                        bfs(q.first+i, q.second+j, d, true);
                    }
                }
            }
        }
        if(0 <= q.first-1){
            if(S.at(q.first-1).at(q.second) == '#'){
                rep2(i, -2, 0){
                    rep2(j, -2, 3){
                        bfs(q.first+i, q.second+j, d, true);
                    }
                }
            }
        }
        if(q.second+1 < W){
            if(S.at(q.first).at(q.second+1) == '#'){
                rep2(i, -2, 3){
                    rep2(j, 1, 3){
                        bfs(q.first+i, q.second+j, d, true);
                    }
                }
            }
        }
        if(0 <= q.second-1){
            if(S.at(q.first).at(q.second-1) == '#'){
                rep2(i, -2, 3){
                    rep2(j, -2, 0){
                        bfs(q.first+i, q.second+j, d, true);
                    }
                }
            }
        }
    }
    if(mv.at(Dh).at(Dw) == INF){
        cout << -1 << endl;
    }
    else{
        cout << mv.at(Dh).at(Dw) << endl;
    }
}


Measured memory_bytes: 13484
public class Main {
    public static void main(String[] args) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        String a = sc.nextLine();
        if(a.equals("ABC"))
        System.out.println("ARC");
        else if(a.equals("ARC"))
        System.out.println("ABC");
    }
}

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

int main(){
	string hyu, num = "";
	int len, ans=0, z;
	while(getline(cin,hyu)){
		len = hyu.size();
		for(int i=0;i<len;i++){
			z = hyu[i];
			if(z>=48&&z<=57){
				num += hyu[i];
			}
			else {
				try
				{
					ans += stoi(num);
				}
				catch (const std::exception&)
				{}
				num = "";
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3208
#include <cstdio>
#include <algorithm>
#include <vector>

#define fin stdin
#define fout stdout

using namespace std;

//FILE *fin = fopen("x.in", "r"), *fout = fopen("x.out", "w");

typedef long long i64;

const int nmax = 1e5;
bool f[nmax + 1];

int main() {
    int n, m;
    fscanf(fin, "%d%d", &n, &m);
    for (int i = 1; i <= m; ++ i) {
        int x, y;
        fscanf(fin, "%d%d", &x, &y);
        f[ x ] ^= 1;
        f[ y ] ^= 1;
    }

    int ans = 1;
    for (int i = 1; i <= n; ++ i) {
        if (f[ i ]) ans = 0;
    }

    if (ans == 1)
        fprintf(fout, "YES\n");
    else
        fprintf(fout, "NO\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
int main(void) {
  string s;

  cin>>s;
  int n=s.length();
  for(int i=2; i<n; i+=2) {
    if(s.substr(0, (n-i)/2)==s.substr((n-i)/2, (n-i)/2)) {
      cout<<n-i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc124/tasks/abc124_b
#include <bits/stdc++.h>
using namespace std;

int main(void){
  int N;
  cin >> N;
  int H[N] = {0};
  for (int i = 0; i < N; i++)  cin >> H[i];

  int count = 0;
  int canseeH = 0;
  for (int i = 0; i < N; i++){
    if (canseeH <= H[i]){
      count++;
      canseeH = H[i];
    }
  }

  cout << count << endl;
}

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

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif
#define int long long
#define ld1 long double
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define cint int t;cin>>t;while(t--)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define MAXN (int)1e6 + 11
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)
template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
    for(int i=0;i<v.size();i++) {
        if(i) out << " ";
        out << v[i];
    }
    return out << endl;
}

const int mod=998244353;
//const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int h1,h2,m1,m2,k;

void solve(){
    cin>>h1>>m1;
    cin>>h2>>m2;
    cin>>k;

    int t=60*h1+m1;
    int t2=60*h2+m2;

    if(t>t2){
        t2+=24*60;
    }

    int diff=t2-t;
    cerr<<diff<<endl;
    cout<<diff-k<<endl;
}


int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double end=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(end-beg)/CLOCKS_PER_SEC;
#endif
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

ll dp[2][105][6000];

int main(void) {
  int i,j,k;
  int n,s;
  while(1){
    cin>>n>>s;
    if(n==0)break;
    rep(i,2)rep(j,101)rep(k,6000)dp[i][j][k]=0;
    dp[0][0][0]=1;

    rep(i,101)rep(j,101)rep(k,s+1)if(dp[i%2][j][k]>0){
      dp[(i+1)%2][j][k]+=dp[i%2][j][k];
      dp[(i+1)%2][j+1][min(k+i,s+1)]+=dp[i%2][j][k];
      dp[i%2][j][k]=0;
    }
    cout<<dp[i%2][n][s]<<endl;
  }
}


Measured memory_bytes: 12556
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vint h(n+1);
   	REP(i,1,n+1){
        cin>>h[i];
    }
    vint dp(n+1);
    REP(i,2,n+1){
        if(i-2>=1){
            dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
        }
        else{
            dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
        }
    }
    cout<<dp[n]<<'\n';
    return(0);
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

fn main() {
  let a = read::<String>();
  let b = read::<String>();

  let a_v = a.chars().collect::<Vec<char>>();
  let b_v = b.chars().collect::<Vec<char>>();

  if check(&a_v, &b_v) && check(&b_v, &a_v) {
    println!("Yes");
  } else {
    println!("No");
  }
}

fn check(a: &Vec<char>, b: &Vec<char>) -> bool {
  let mut map = HashMap::new();
  let mut result = true;

  for (i, v) in a.iter().enumerate() {
    let value = b[i];
    if map.contains_key(&v) {
      if *map.get(&v).unwrap() != value {
        result = false
      }
    } else {
      map.insert(v, value);
    }
  }
  result
}

// ==============================

// use std::io::*;
// use std::str::FromStr;

// pub fn read<T: FromStr>() -> T {
//   let stdin = stdin();
//   let stdin = stdin.lock();
//   let token: String = stdin
//     .bytes()
//     .map(|c| c.expect("failed to read char") as char)
//     .skip_while(|c| c.is_whitespace())
//     .take_while(|c| !c.is_whitespace())
//     .collect();
//   token.parse().ok().expect("failed to parse token")
// }

// use std::collections::HashMap;

// fn main() {
//   let a = read::<String>();
//   let b = read::<String>();

//   if check(&a, &b) && check(&b, &a) {
//     println!("Yes");
//   } else {
//     println!("No");
//   }

//   // println!("{}", max_v);
// }

// fn check(a: &str, b: &str) -> bool {
//   let mut map = HashMap::new();
//   let mut result = true;

//   for (i, v) in a.chars().enumerate() {
//     let value = b.chars().nth(i).unwrap();
//     if map.contains_key(&v) {
//       if *map.get(&v).unwrap() != value {
//         result = false
//       }
//     } else {
//       map.insert(v, value);
//     }
//   }
//   result
// }


Measured memory_bytes: 6396
N = int(input())
S = input()
l = 0

for i in range(1,N):
    a = S[:i]
    b = S[i:]
    k = 0
    for j in range(len(a)):
        if a[j] not in a[:j]:
            if a[j] in b:
                k+=1
    if k>l:
        l = k
        
print(l)

Measured memory_bytes: 3060
#pragma GCC optimize "O3"
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define REP_FROM(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define REP_REV(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define REP_FROMREV(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#ifndef LOCAL
#define cerr if (false) cerr
#endif
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <class T> T sq(T x) { return x * x; }
template <class T> T clamp(T a, T l, T r) { return min(max(a, l), r); } // [l, r]
const double EPS = 1e-10;
const double PI  = acos(-1.0);

void solve(int a, int b, int c, int d, int e, int f) {
	double x, y;
	y = (d*c-a*f)/(double)(d*b-a*e);
	x = (c-b*y)/(double)a;
	printf("%.3f %.3f\n", x, y);
}

int main(int argc, char *argv[]) {
	// Something to do
	int a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f) {
		solve(a,b,c,d,e,f);
	}
	return 0;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    boost;
    time_t tic, toc;

    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, h, w, u, v, x, y;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s, t, tmp;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;
        if(n%1000 == 0) cout << 0 << nl;
        else{
            ll rem = n / 1000;
            cout << 1000*(rem + 1) - n << nl;
        }
    } 
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
const int N=52,M=1e9+7,Z=2505;
int n,k,dp[N][N][N*N<<1];
void ck(int &x){
	if(x>=M)x-=M;
}
int main(){
	scanf("%d %d",&n,&k);
	if(k&1||k>n*n/2){
		puts("0");
		return 0;
	}
	dp[0][0][Z]=1;
	for(int i=0;i<n;++i){
		for(int o=0;o<=i;++o){
			for(int u=0;u<=5005;++u){
				if(!dp[i][o][u])continue;
				dp[i+1][o][u]+=dp[i][o][u];ck(dp[i+1][o][u]);
				dp[i+1][o][u]+=1ll*dp[i][o][u]*o%M;ck(dp[i+1][o][u]);
				dp[i+1][o][u]+=1ll*dp[i][o][u]*o%M;ck(dp[i+1][o][u]);
				dp[i+1][o+1][u-2*i]+=dp[i][o][u];ck(dp[i+1][o+1][u-2*i]);
				if(o)dp[i+1][o-1][u+2*i]+=1ll*dp[i][o][u]*o*o%M;ck(dp[i+1][o-1][u+2*i]);
			}
		}
	}
	printf("%d\n",dp[n][0][Z+k]);
}

Measured memory_bytes: 53760
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,K;
vector<ll> A;
void input(){
    fast_io();
    cin >> N >> K;
    A = fetch_vec<ll>(N);
}

int solve(){
    for (int i = 0; i < N-K; i++)
    {
        if(A[i]<A[i+K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin>>n;
    ll ans=0;
        ans=2*(n/11);
        if(n%11==0)ans+=0;
        else if(n%11<=6)ans++;
        else ans+=2;
        cout<<ans<<endl;
}


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

class Cube{
public:
	int f[6];
	Cube(){}
		void roll_z(){roll(1,2,4,3);}
		void roll_y(){roll(0,2,5,3);}//to W
		void roll_x(){roll(0,1,5,4);}//to N
		void roll(int i,int j,int k, int l){
			int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
		}
		void move(char ch){
			if(ch=='E')for (int i = 0; i < 3; ++i) {roll_y();}
			if(ch=='W')roll_y();
			if(ch=='N')roll_x();
			if(ch=='S')for (int i = 0; i < 3; ++i) {roll_x();}
		}
};
bool eq(Cube c1,Cube c2){
	for (int i = 0; i < 6; ++i) {
		if (c1.f[i] != c2.f[i]) {return false;}
	}return true;
}

bool equal(Cube c1,Cube c2){
	for (int i = 0; i < 6; ++i) {
		for (int j = 0; j < 4; ++j) {
			if (eq(c1,c2)) return true;
						c1.roll_z();
		}
		if (i%2==0) {c1.roll_y();}
		else{c1.roll_x();}
	}
	return false;
}


int main() {
	int n;
	cin>>n;
	Cube c[n];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 6; ++j){
			cin>>c[i].f[j];
		}
	}
	for (int i = 0; i < n-1; ++i) {
		for (int j = i+1; j < n; ++j) {
			if (equal(c[i],c[j])){cout<<"No"<<endl;return 0;}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

set<ll> enumDivisor(ll n) {
	set<ll> result;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0) continue;
		result.insert(i);
		result.insert(n / i);
	}
	return result;
}

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

	ll n;
	cin >> n;
	int ans = 0;
	for (ll x : enumDivisor(n)) {
		if (x == 1) continue;
		ll tmp = n;
		while (tmp % x == 0) tmp /= x;
		tmp %= x;
		if (tmp == 1) ans++;
	}
	ans += enumDivisor(n - 1).size() - 1;
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  string s;
  cin >> s;

  int num = 0;
  int b = 1;

  for(int i = 0; i < N; i++){
    if(s[i] == 'a'){
      if(num < A + B){
        cout << "Yes" << endl;
        num++;
      } else{
        cout << "No" << endl;
      }
    }
    else if(s[i] == 'b'){
      if(num < A + B && b <= B){
        cout << "Yes" << endl;
        num++;
        b++;
      } else{
        cout << "No" << endl;
      }
    }
    else{
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 896
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		long b=sc.nextLong();
		long n=sc.nextLong();
		System.out.println(a*Math.min((b-1),n)/b-Math.min(n,(b-1))/b*a);
	}
}

Measured memory_bytes: 35744
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const double PI = 4.0*atan(1.0);

int n,k;
vl a,b;

int main(){
	cin>>n>>k;
	if(!k){
		ll res=0;
		for(int i=0;i<n;i++){
			ll A,B;
			cin>>A>>B;
			if(A==0) res+=B;
		}
		cout<<res<<endl;
		return 0;
	}
	a=b=vl(n);
	ll res=0;
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	for(int i=0;i<30;i++) if(k&1<<i){
		ll tmp=0;
		for(int j=0;j<n;j++){
			bool B=1;
			for(int l=0;l<30;l++){
				if(i==l&&(a[j]&1<<l)||l>i&&(!(k&1<<l))&&(a[j]&1<<l)) B=0;
			}
			if(B) tmp+=b[j];
		}
		res=max(res,tmp);
	}
	ll tmp=0;
	for(int	i=0;i<n;i++){
		bool B=1;
		for(int j=0;j<30;j++){
			if((!(k&1<<j))&&(a[i]&1<<j)) B=0;
		}
		if(B) tmp+=b[i];
	}
	res=max(res,tmp);
	cout<<res<<endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e6 + 5;
const ll nex = 2e5 + 5;

ll cek[nax], a[nex], n, freq[nax];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	set<ll> st;
	for(ll i = 0; i < n; i++){
		cin >> a[i];
		freq[a[i]]++;
	}
	sort(a, a + n);
	ll ans = 0;
	for(ll i = 0; i < n; i++){
		if(!cek[a[i]]){
			if(freq[a[i]] == 1){
				ans++;
			}
			for(ll j = a[i]; j < nax; j += a[i]){
				cek[j] = 1;
			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 20744
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC125C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = ReadInt;
            var A = ReadInts;

            int[] gcdL = new int[N + 2];
            int[] gcdR = new int[N + 2];
            for (int i = N; i >= 1; i--)
            {
                gcdR[i] = Gcd(gcdR[i + 1], A[i - 1]);
            }

            int ans = 0;
            for (int i = 1; i <= N; i++)
            {
                int gcd = Gcd(gcdL[i - 1], gcdR[i + 1]);
                ans = Math.Max(ans, gcd);

                gcdL[i] = Gcd(gcdL[i - 1], A[i - 1]);
            }

            Console.WriteLine(ans);
        }

        /// <summary>
        /// 最大公約数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 29020
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []a = new int[n];
		int []b = new int[n];
		
		for(int i = 0; i < n ;i++) {
			a[i] = sc.nextInt();
			b[i] = a[i];
 		}
		Arrays.sort(b);
		
		int k = b[n/2];
		int l = b[n/2 - 1];
		
		for(int i = 0 ; i < n ;i++) {
			if(a[i] < k) {
				System.out.println(k);
			}
			if(a[i] >= k) {
				System.out.println(l);
			}
		}

	}

}


Measured memory_bytes: 94684
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long h = sc.nextLong();
    long[] a = new long[n];
    long[] b = new long[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextLong();
      b[i] = sc.nextLong();
    }
    Arrays.sort(a);
    Arrays.sort(b);

    long count = 0;
    for(int i = b.length - 1; i >= 0; i--){
      if(b[i] <= a[a.length - 1]) break;
      h -= b[i];
      count++;
      if(h <= 0){
        System.out.println(count);
        System.exit(0);
      }
    }
    
    System.out.println(count + (long)Math.ceil(h / (double)a[a.length - 1]));
  }
}

Measured memory_bytes: 76856
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.length();
  FOR(i,0,n){
    bool ok = true;
    FOR(j,0,n){
      if(s[(i+j)%n]!=t[j]){
        ok = false;
        break;
      }
    }
    if(ok){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
using namespace std;
map<char, char> conv;

main() {
  int n, m;
  while((cin >> n) && n) {
    conv.clear();
    for(int i = 0; i < n; ++i) {
      char a, b;
      cin >> a >> b;
      conv[a] = b;
    }
    cin >> m;
    for(int i = 0; i < m; ++i) {
      char c;
      cin >> c;
      if(conv[c] == 0) cout << c;
      else             cout << conv[c];
    }
    cout << endl;
  }
}

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

int main(){
  string S , T ; 
  cin >> S >> T ; 
  string U ; 
  int N = S.size() ; 
  
  for(int i = 1 ; i <= N ; i++){
    U = S.substr(N-i,i) + S.substr(0,N - i ) ; 
    //cout << U << endl ;
    if(U == T){
      cout << "Yes" << endl;
      return 0 ; 
    }
  }
  
  cout << "No" << endl ; 
}


Measured memory_bytes: 3564
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int i,o,t,j,l,s,z;
  cin>>i>>o>>t>>j>>l>>s>>z;

  long k=o;
  long tmp = min(l,min(i,j));
  k += tmp*3;
  k += ((l-tmp)/2 + (i-tmp)/2 + (j-tmp)/2)*2;

  long p=o;
  long tp = min(l,min(i,j))-1;
  if(tp>=0){
    p += tp*3;
    p += ((l-tp)/2 + (i-tp)/2 + (j-tp)/2)*2;
  }

  cout << max(k,p) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  int a=1e9,ans=0;
  rep(i,n){
    int p;cin>>p;
    if(a>p){
      ans++;
      a=p;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
long long v[64],g[300001],n,sum,ans;

int main(){
    cin >> n;
    for(int i = 0 ; i < n ; i += 1){
        cin >> g[i];
        sum += g[i];
        sum %= 1000000007;
        long long a = g[i] , cnt = 0;
        while(a > 0){
            if(a % 2 == 1){
                v[cnt] += 1;
            }
            a /= 2;
            cnt += 1;
        }
    }
    for(int i = 0 ; i < n ; i += 1){
        long long a = g[i] , cnt = 0;
        ans += sum + (n-i-2)*(g[i]%1000000007);
        ans %= 1000000007;
        while(a > 0){
            if(a % 2 == 1){
                v[cnt] -= 1;
                ans -= v[cnt]*(((1ll << cnt)*2ll)%1000000007);
                ans %= 1000000007;
                ans += 1000000007;
                ans %= 1000000007;
            }
            a >>= 1;
            cnt += 1;
        }
        sum -= g[i];
        sum %= 1000000007;
        sum += 1000000007;
        sum %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(){
    int i, j, k;
    int n, x;
    int count;

    while(1){
        scanf("%d %d ", &n, &x);
        if(n==0&&x==0)break;
        count=0;
        for(i=1;3*i+3<=x;i++){
            for(j=i+1;i+2*j+1<=x;j++){
                for(k=n;k>j;k--){
                    if(x==i+j+k){
                        count++;
                        break;
                    }else if(x>=i+j+k){
                        break;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	int k; cin >> k;
	int a,b; cin >> a >> b;
	for (int i=a;i<=b;i++){
		if (i%k==0){
			cout << "OK" << "\n";
			return 0;
		}
	}
	cout << "NG" << "\n";

}


Measured memory_bytes: 3636
import collections as c
import sys
s = input()
l = len(s)

if l == 1:
	print("YES")
else:
	S = c.Counter(list(map(str,s)))
	if len(S.keys()) == 1:
		print("NO")
		sys.exit()
	elif len(S.keys()) == 2:
		if l == 2:
			print("YES")
		else:
			print("NO")
		sys.exit()

	cnt = set(list(S.values()))

	if len(cnt) == 3:
		print("NO")
	elif len(cnt) == 2:
		a,b = cnt
		if abs(a-b) <= 1:
			print("YES")
		else:
			print("NO")
	else:
		print("YES")

Measured memory_bytes: 4340
N, D = map(int, input().split())
items = []
for i in range(N):
    items.append(tuple(map(int, input().split())))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if i == j:
            continue
        tmp = 0
        for k in range(D):
            tmp += (items[i][k] - items[j][k]) ** 2
        if pow(tmp, 0.5).is_integer():
            ans += 1
print(ans)


Measured memory_bytes: 3188
#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

#べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い)
def modinv2(a,m):
    return pow(a,m-2,m)


N = int(input())
A = list(map(int,input().split()))
P = 10**9+7

if N == 1:
    ans = 1

else:

    inv = modinv2(A[0],P)
    g = A[0]
    invlist = []
    seki = A[0]%P

    for i in range(1,N):
        inv = (inv+modinv2(A[i],P))%P
        seki = seki*A[i]%P

    g = gcd(A[0],A[1])
    l = A[0]//g*A[1]
    cc = modinv2(g,P)
    for i in range(2,N):
        g = gcd(l,A[i])
        l = l//g*A[i]
        cc = cc*modinv2(g,P)%P

    ans = (inv*seki%P)*cc%P

print(ans)

Measured memory_bytes: 4084