akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}


int main()
{
    int n, m;
    vll v;
    
    ci >> n >> m;

    llint a, b;
    rep(i, n) {
	ci >> a >> b;
	v.pb({a, b});
    }

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

    llint sum = 0;
    rep(i, n) {
	if(m >= v[i].second) {
	    sum += v[i].first * v[i].second;
	    m -= v[i].second;
	} else {
	    sum += m * v[i].first;
	    break;
	}
    }

    co << sum << en;
  
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  cout << x+y/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;


int main(){
    int a, b;
    cin >> a >> b;
    cout << a*a-b << endl;
    return 0;
}


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

def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    INF = 10**12
    dp = [INF] * N
    dp[0] = 0
    for i in range(1,N):
        dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(K,i)+1))
    print(dp[N-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 20632
def merge(arr,left,mid,right)
  p = mid - left
  q = right - mid
  l1 = arr[left,p]
  l2 = arr[mid,q]
  l1 << 1e10
  l2 << 1e10
  i = j = 0
  (left...right).map do |k|
    if l1[i] <= l2[j]
      arr[k] = l1[i]
      i += 1
    else
      arr[k] = l2[j]
      j += 1
      $cnt += p-i
    end
  end
end
def mergeSort(arr,left,right)
  if left + 1 < right
    mid = (left+right)/2
    mergeSort(arr,left,mid)
    mergeSort(arr,mid,right)
    merge(arr,left,mid,right)
  end
end
n = gets.to_i
arr = gets.split.map(&:to_i)
$cnt = 0
mergeSort(arr,0,n)
p $cnt

Measured memory_bytes: 40980
#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>
#include<complex>

using namespace std;

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

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s;
    //cin >> s;
    int a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi T(N), A(N); REP(i, N) cin >> T[i] >> A[i];

    vl dp(N, 0);
    // dp[i] := the minimum value of the coefficient when viewed for the i-th time
    dp[0] = 1;

    vl nt(N), na(N);
    nt[0] = T[0] * dp[0];
    na[0] = A[0] * dp[0];
    for (int i = 1; i < N; i++) {
        dp[i] = max((nt[i - 1] + T[i] - 1) / T[i], (na[i - 1] + A[i] - 1) / A[i]);
        nt[i] = T[i] * dp[i];
        na[i] = A[i] * dp[i];
    }

    ll ans = nt[N - 1] + na[N - 1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
if b[-1]==b[-2]:
  for i in range(n):
    print(b[-1])
else:
  p=a.index(b[-1])
  for i in range(n):
    if i==p:
      print(b[-2])
    else:
      print(b[-1])

Measured memory_bytes: 14112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll A, B; cin >> A >> B;
    cout << A*B << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	if (t.size() > s.size()) {
		cout << "UNRESTORABLE" << "\n";
		return 0;
	}
	string ans = s;
	bool ok = false;
	for (int i = s.size()-t.size(); i >= 0; i--) {
		if (s[i] == t[0] || s[i] == '?') {
			int j = i;
			int m = 0;
			for (m = 0; m < t.size(); m++) {
				if (s[j] == t[m]) {
					j++;
					continue;
				}
				if (s[j] == '?') {
					j++;
					continue;
				}
				break;
			}
			if (m==t.size()) {
				ok = true;
				int n = 0;
				for (int k = i; k < i + t.size(); k++) {
					ans[k] = t[n];
					n++;
				}
				break;
			}
		}
	}

	if (!ok) {
		cout << "UNRESTORABLE" << "\n";
		return 0;
	}
	for (int i = 0; i < ans.size(); i++) {
		if (ans[i]=='?') {
			ans[i] = 'a';
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char S[101];
    scanf("%s",S);
    int res=0;
    int i=0;
    int N=strlen(S);
    for(i=0;i<N;i++){
        if(S[i]!=S[N-1-i]){
            res++;
        }
    }
    if(res!=0){
        printf("%d\n",res/2);
    }
    else{
        printf("%d\n",res);
    }

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
int main(void){
	int n,i,j,f[110],p[110][11],k,cnt,tmp,ans=-INF;
	fill(f,f+110,0);
	cin >> n;
	for(i=0; i<n; i++){
		for(j=0; j<10; j++){
			f[i] *= 2;
			cin >> k;
			f[i] += k;
		}
	}
	for(i=0; i<n; i++){
		for(j=0; j<11; j++){
			cin >> p[i][j];
		}
	}
	for(i=1; i<1024; i++){
		tmp = 0;
		for(j=0; j<n; j++){
			cnt = 0;
			for(k=0; k<10; k++){
				if( (f[j]&(1<<k))>0 && (i&(1<<k))>0 ){
					cnt++;
				}
			}
			tmp += p[j][cnt];
		}
		ans = max(tmp,ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
S = str(input())
sam = ['A','C','G','T']
box = []
count = 0
for i in range(len(S)):
    if i == 0 and S[i] in sam:
        count+=1
    elif i > 0:
        if count == 0 and S[i] in sam:
            count+=1
        elif S[i] in sam and S[i-1] in sam:
            count+=1
        else:
            box.append(count)
            count=0
box.append(count)
        
print(max(box))
        

Measured memory_bytes: 3064
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int INF = 1e9 + 7;
int _;

int main() {
	INIT
	int a, b, c, k, f = 1;
	cin >> a >> b >> c >> k;
	while (a >= b) {
		if (!k) {
			f = 0;
			break;
		}
		b *= 2;
		--k;
	}
	while (b >= c) {
		if (!k) {
			f = 0;
			break;
		}
		c *= 2;
		--k;
	}
	if (f) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3644
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] ary=new int[n];
        for(int i=0;i<n-1;i++){
            ary[sc.nextInt()-1]++;
        }
        for(int e : ary){
            System.out.println(e);
        }
    }
}

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<double> H(N);
  
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
    H.at(i) = abs(A - (T - H.at(i) * 0.006));
  }
  
  double res = 1000000000;
  int FindID = 1;
    
  for (int i = 0; i < N; i++) {
    if (res > H.at(i)) {
      res = H.at(i);
      FindID = i + 1;
    }
  }
  
  cout << FindID << endl;
}

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

import sys
import math
import itertools

def main():
    n, m, k = map(int, sys.stdin.readline().split())
    fs = [tuple(map(int, sys.stdin.readline().split())) for _ in range(m)]
    bs = [tuple(map(int, sys.stdin.readline().split())) for _ in range(k)]

    g = [[] for _ in range(n)]
    for u, v in fs:
        g[u - 1].append(v - 1)
        g[v - 1].append(u - 1)

    bg = [[] for _ in range(n)]
    for u, v in bs:
        bg[u - 1].append(v - 1)
        bg[v - 1].append(u - 1)

    ccmembs = []
    ccmap = [-1] * n
    def color_component(ccid, root):
        stack = [root]
        ccmap[root] = ccid
        nmemb = 1
        while len(stack) > 0:
            u = stack.pop()
            for v in g[u]:
                if ccmap[v] < 0:
                    ccmap[v] = ccid
                    nmemb += 1
                    stack.append(v)
        return nmemb

    for u in range(n):
        if ccmap[u] < 0:
            ccmembs.append(color_component(len(ccmembs), u))

    for u in range(n):
        c = (ccmembs[ccmap[u]]
                - sum(1 for v in g[u] if ccmap[u] == ccmap[v])
                - sum(1 for v in bg[u] if ccmap[u] == ccmap[v])
                - 1)
        print(c, end=(' ' if u != n - 1 else '\n'))

if __name__ == '__main__':
    main()

Measured memory_bytes: 69836
def main():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))
    hyouka = [0]*(N-K+1)
    """
    kekka = 1
    for i in range(N-K+1):
        if i == 0:
            for j in As[i:i+K]:
                kekka *= j
                hyouka[i]=kekka
        else:
            kekka = kekka/As[i-1]*As[i+K-1]
            hyouka[i]=int(kekka)
    #print(hyouka)
    for j in range(len(hyouka)):
        if j>0:
            if hyouka[j] > hyouka[j-1]:
                print('Yes')
            else:
                print("No")
    """
    for i in range(N-K):
        if As[i] < As[i+K]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 31300
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll mod=1e9+7;

vector<vector<ll>> to;

ll n,k;

ll ans=1;

void dfs(ll v,ll p=-1){
    ll c;
    if(p==-1) c=k-1;
    else c=k-2;
    for(auto x:to[v]){
        if(x==p) continue;
        ans*=c;
        ans%=mod;
        c--;
        dfs(x,v);
    }
    return ;
}

int main(){
    cin >> n >> k;
    to=vector<vector<ll>>(n);
    rep(i,n-1){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0);
    ans*=k;
    ans%=mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13472
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var q int
var X, Y string

func lcs(X, Y string) int {
	lenX := len(X)
	lenY := len(Y)
	dp := make([][]int, lenX+1)
	for i := 0; i < lenX+1; i++ {
		dp[i] = make([]int, lenY+1)
	}

	res := 0
	for i := 1; i < lenX+1; i++ {
		for j := 1; j < lenY+1; j++ {
			if X[i-1] == Y[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = maxInt(dp[i-1][j], dp[i][j-1])
			}
			//fmt.Println(dp)
			res = maxInt(res, dp[i][j])
		}

	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	q = nextInt()

	for i := 0; i < q; i++ {
		X = nextStr()
		Y = nextStr()

		fmt.Println(lcs(X, Y))
	}
}



Measured memory_bytes: 18924
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;
    
    vector<string> words;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        words.push_back(s);
    }
    
    sort(words.begin(), words.end());
    
    unsigned long answer = 0;
    int count = 0;
    for(int i=1;i<n;i++)
    {
        
        string s1 = words.at(i);
        string s2 = words.at(i-1);
        
        if(s1==s2)
        {
            count++;
            answer += count;
        }
        else
        {
            count = 0;
        }
        
    }
    
    
    cout << answer;
    
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  vector<vector<ll>> book(n, vector<ll>(m));
  vector<ll> c(n);
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> book[i][j];
  }
  ll ans = INF64;
  for(int bit = 1; bit < 1<<n; ++bit) {
    vector<ll> rikai(m, 0);
    ll charge = 0;
    rep(i, n) if(bit & 1<<i) {
      charge += c[i];
      rep(j, m) rikai[j] += book[i][j];
    }
    bool ok = true;
    rep(j, m) if(rikai[j] < x) ok = false;
    if(ok) chmin(ans, charge);
  }
  if(ans != INF64) cout << ans << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int N = 505;
int n;
ll s[N], t[N], u[N], v[N];
ll a[N][N];
int T[N][N];
int c[N];
void transpose(){
    for (int i = 1; i <= n; i++){
        for (int j = i+1; j <= n; j++) swap(T[i][j],T[j][i]);
        swap(u[i],v[i]);
        swap(s[i],t[i]);
    }
}
void fix(ll x){
    for (int i = 1; i <= n; i++){
        if (t[i] == 0){
            c[i] = n-1;
            for (int j = 1; j <= n; j++){
                c[i] -= T[j][i];
            }
        }
        else c[i] = 0;
    }
    for (int i = 1; i <= n; i++){
        if (s[i] == 1 && ((u[i] & x))){
            bool done = false;
            for (int j = 1; j <= n; j++) done |= T[i][j];
            if (done) continue;
            //printf("need to fix row %d OR 1\n",i);
            for (int j = 1; j <= n; j++){
                if (c[j] > 0){
                    //printf("can use column %d\n",j);
                    c[j]--;
                    T[i][j] = 1;
                    break;
                }
            }
        }
    }
}
void gen(ll x){
    //printf("genning %llu\n",x);
    memset(T,0,sizeof(T));
    for (int i = 1; i <= n; i++){
        if (s[i] == 0 && (u[i] & x)) for (int j = 1; j <= n; j++) T[i][j] = 1;
        if (t[i] == 0 && (v[i] & x)) for (int j = 1; j <= n; j++) T[j][i] = 1;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if (s[i] == t[j]){
                if (s[i] == 0) T[i][j] = (u[i] & x)||(v[j] & x);
                else T[i][j] = (u[i] & x)&&(v[j] & x);
            }
        }
    }
    fix(x);
    transpose();
    fix(x);
    transpose();
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if (T[i][j]) a[i][j] |= x;
        }
    }
}
bool check(){
    for (int i = 1 ; i <= n; i++){
        ll RAND = a[i][1], ROR = 0, CAND = a[1][i], COR = 0;
        for (int j = 1; j <= n; j++){
            RAND &= a[i][j];
            ROR |= a[i][j];
            CAND &= a[j][i];
            COR |= a[j][i];
        }
        if (s[i] == 0 && u[i] != RAND) return 0;
        if (s[i] == 1 && u[i] != ROR) return 0;
        if (t[i] == 0 && v[i] != CAND) return 0;
        if (t[i] == 1 && v[i] != COR) return 0;
    }
    return 1;
}
int main(){
    scanf("%d",&n);
    for (int i = 1; i <= n; i++) scanf("%llu",&s[i]);
    for (int i = 1; i <= n; i++) scanf("%llu",&t[i]);
    for (int i = 1; i <= n; i++) scanf("%llu",&u[i]);
    for (int i = 1; i <= n; i++) scanf("%llu",&v[i]);
    for (int i = 0; i < 64; i++) gen(1llu<<i);
    if (!check()){
        printf("-1\n");
        return 0;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            printf("%llu ",a[i][j]);
        }
        printf("\n");
    }
}


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

int main() {
  // ここにプログラムを追記
  int a;
  cin >> a;
  if(a%3==0&&!(a==111)){
    cout << 0;
  }else if(a%3==0){
    cout << 3;
  }else if(a%3==2){
    cout << 2;
  }else{
    cout << 1;
  }
  
}

Measured memory_bytes: 3492
def main():
    N, K = map(int, input().split())
    A    = [int(i)-1 for i in input().split()]

    visited_town = []
    current_town = 0
    loop_flg     = False
    visited_town.append(current_town)
    set_visted_town = set(visited_town)
    for i in range(K):
        current_town = A[current_town]
        if current_town in set_visted_town:
            visited_town.append(current_town)
            loop_flg = True
            break
        visited_town.append(current_town)
        set_visted_town.add(current_town)


    if loop_flg:
        loop_start = visited_town.index(current_town)
        loop_end   = len(visited_town) - 1
        loop_length = loop_end - loop_start
        last_index = (K-loop_start)%loop_length
        current_town = visited_town[loop_start+last_index]

    print(current_town+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32316
#include<bits/stdc++.h>
using namespace std;
struct node{
	int u,v,dis;
}edge[2000005];
long long n,m,ans=0;
int f[50005];
int rk[50005];
int num=1;
void init()
{
	for(int i=1;i<=n;i++)
	{
		f[i]=i;
		rk[i]=0;
	}
}
int find(int x)
{
	if(f[x]!=x) f[x]=find(f[x]);
	return f[x];
}
void Union(int a,int b)
{
	int u=find(a),v=find(b);
	if(u==v) return;
	if(rk[u]>rk[v]) f[v]=u;
	else f[u]=v;
	if(rk[u]==rk[v]) rk[v]++;
}
bool cmp(node a,node b)
{
	if(a.dis<b.dis) return true;
	else return false;
}
void Kruskal()
{
	sort(edge,edge+m,cmp);
	for(int i=0;i<m&&num<n;i++)
	if(find(edge[i].u)!=find(edge[i].v))
	{
		Union(edge[i].u,edge[i].v);
		ans+=edge[i].dis;
		num++;
	}
}
int main()
{
	cin>>n>>m;
	init();
	for(int i=0;i<m;i++)
	scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].dis);
	Kruskal();
	if(num<n) cout<<"orz";
	else cout<<ans<<endl;
}


Measured memory_bytes: 4500
#include<iostream>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
bool b[301];
int main() {
	int n, m; cin >> n >> m;
	vector<deque<int> > v;
	for (int i = 0; i < n; i++) {
		deque<int>d;
		for (int j = 0; j < m; j++) {
			int k; cin >> k;
			d.push_back(k);
		}
		v.push_back(d);
	}
	int ans = 114514;
	while (true){
		int cnt = 0, num;
		int count[301] = {};
		for (int i = 0; i < n; i++) {
			int k = v[i].front();
			count[k]++;
			if (count[k] > cnt) {
				cnt = count[k];
				num = k;
			}
		}
		b[num] = true;
		ans = min(ans, cnt);
		for (int i = 0; i < n; i++) {
			while (b[v[i].front()]) { 
				v[i].pop_front(); 
				if (v[i].size() == 0) {
					cout << ans << endl;
					char c; cin >> c;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 1152
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
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...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,ans;
vint v;

main(){
	cin>>n;
	rep(i,n){
		int t;
		cin>>t;
		v.pb(t);
	}
	sort(rall(v));
	rep(i,n)ans+=v[i];
	ans-=v[0]/2;
	dans;
}


Measured memory_bytes: 256
def main():
    res = 0
    ts = []
    for _ in range(5):
        t = int(input())
        if t % 10 == 0:
            res += t
        else:
            ts.append(t)
    for (i, t) in enumerate(sorted(ts, key=lambda x: x % 10)):
        if i == 0:
            res += t
        else:
            res += t + 10 - t % 10
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}

int a[100000];
int main(void)
{
	int n,k,i;
	scanf("%d%d",&n,&k);
	printf("%d\n",(n-1+k-2)/(k-1));
	return 0;
}
    
    
    

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

//const int maxn
int n,m;
int ans[4];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	n=read();
	string s;
	for(int i=0;i<n;i++){
		cin >> s;
		if(s[0]=='A') ++ans[0];
		if(s[0]=='W') ++ans[1];
		if(s[0]=='T') ++ans[2];
		if(s[0]=='R') ++ans[3];
	}
	printf("AC x %d\n",ans[0]);
	printf("WA x %d\n",ans[1]);
	printf("TLE x %d\n",ans[2]);
	printf("RE x %d\n",ans[3]);
	return 0;
}


Measured memory_bytes: 3732
thres = 10 ** 5

isPrime = [True] * (thres + 5)
isPrime[0] = isPrime[1] = False
idx = 2
while (idx * idx) <= thres:
    if isPrime[idx] is True:
        for k in range(idx + idx, thres, idx):
            isPrime[k] = False
    idx += 1

isLike = [False] * (thres + 5)
isLike[0] = False
for i in range(1, thres + 1):
    if isPrime[i] is True and isPrime[(i + 1) // 2] is True:
        isLike[i] = True

cum = [0] * (thres + 5)
cum[0] = cum[1] = 0
for i in range(1, thres + 1):
    if isLike[i] is True:
        cum[i] = cum[i - 1] + 1
    else:
        cum[i] = cum[i - 1]

q = int(input())

for i in range(q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l - 1])


Measured memory_bytes: 5748
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
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%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll a[100002];
    for (int i = 1; i <=n; ++i)
    {
    	cin>>a[i];
    }
    ll dp[100002];
    dp[n]=0;
    dp[n-1]=abs(a[n-1]-a[n]);
    for (int i = n-2; i >0; --i)
    {
    	dp[i]=min(dp[i+1]+abs(a[i]-a[i+1]),dp[i+2]+abs(a[i]-a[i+2]));
    }
    cout<<dp[1]<<'\n';
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,k;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    int ans;
    ans = 1;
    if(n%k==0)ans=0;
    cout<<ans<<newl;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){ 
  int N;
  cin >> N;
  FOR(i, 1, 10){
    if(N % i == 0 && N/i >= 0 && N/i <= 9){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    


	int n;
	cin>>n;

	map<string,int>m;

	fo(i,n){
		string s;
		cin>>s;
		m[s]++;
	}
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";
    
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

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

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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n);

    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        A[i] -= 1;
    }

    for (int i = 0; i < n; ++i) {
        cin >> B[i];
    }

    for (int i = 0; i < n-1; ++i) {
        cin >> C[i];
    }
    int ret = B[A[0]];
    for (int i = 1; i < n; ++i) {
        ret += B[A[i]];
        if (A[i] - A[i-1] == 1) ret += C[A[i-1]];
    }

    printf("%d\n", ret);

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

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

vector<bool> make_is_prime(int N) {
    vector<bool> prime(N + 1, true);
    if (N >= 0) prime[0] = false;
    if (N >= 1) prime[1] = false;
    for (int i = 2; i * i <= N; i++) {
        if (!prime[i]) continue;
        for (int j = i * i; j <= N; j+= i) {
            prime[j] = false;
        }
    }
    return prime;
}

bool is_prime(long long n) {
    for (long long i = 2; i * i <= n; i++) {
        if(n % i == 0) return false;
    }
    return true;
}

void Main()
{
    ll x;
    cin >> x;
    while(1) {
        if(is_prime(x) == true) {
            cout << x << endl;
            break;
        }
        x++;
    }   
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
<?php
list($S,$T)=sscanf(trim(fgets(STDIN)),"%s %s");
list($A,$B)=sscanf(trim(fgets(STDIN)),"%d %d");
list($U)=sscanf(trim(fgets(STDIN)),"%s");
if($U == $S){
    printf("%d %d",$A-1, $B);
}else{
    printf("%d %d",$A, $B-1);
}

Measured memory_bytes: 3828
n, m = map(int, input().split())
a = [[] for _ in range(n)]

for i in range(n):
  a[i] = list(map(int, input().split()))

b = [0 for _ in range(m)]
for i in range(m):
  b[i] = int(input())

for i in range(n):
  c = 0

  for j in range(m):
    c += a[i][j]*b[j]

  print(c)

Measured memory_bytes: 7988
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    ll C;
    vector<ll> X, V;

    void input() {
        cin >> N >> C;
        rep(i, 0, N) {
            ll x, v;
            cin >> x >> v;
            X.push_back(x);
            V.push_back(v);
        }


    }

    ll calc(int wL, int wR) {
        vector<ll> ruiXL(N + 2);
        vector<ll> ruiXR(N + 2);
        vector<ll> ruiVL(N + 2);
        vector<ll> ruiVR(N + 2);

        for (int i = 0; i < N; ++i) {
//            ruiXL[i + 1] = ruiXL[i] + X[i];
            ruiXL[i + 1] = X[i];
            ruiVL[i + 1] = ruiVL[i] + V[i];
        }
        for (int i = N; i > 0; --i) {
//            ruiXR[i] = ruiXR[i + 1] + X[i];
            ruiXR[i] = C - X[i - 1];
            ruiVR[i] = ruiVR[i + 1] + V[i - 1];
        }

        vector<ll> beneL(N + 2);
        vector<ll> beneR(N + 2);

        for (int i = 0; i <= N + 1; ++i) {
            beneL[i] = ruiVL[i] - wL * ruiXL[i];
            beneR[i] = ruiVR[i] - wR * ruiXR[i];
        }

        for (int i = 0; i <= N; ++i) {
            beneL[i + 1] = max(beneL[i], beneL[i + 1]);
        }
        for (int i = N + 1; i > 0; --i) {
            beneR[i - 1] = max(beneR[i], beneR[i - 1]);
        }

        ll ret = 0ll;
        for (int i = 0; i <= N; ++i) {
            chmax(ret, beneL[i] + beneR[i + 1]);
        }

        return ret;
    }

    void solve() {
        input();

        ll ans = max(calc(1, 2), calc(2, 1));
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 6764
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            if (N <= 9)
            {
                Console.WriteLine(N);
            }
            else if (N <= 99)
            {
                Console.WriteLine(9);
            }
            else if (N <= 999)
            {
                int tmp = N - 99;
                Console.WriteLine(9 + tmp);
            }
            else if (N <= 9999)
            {
                Console.WriteLine(9 + 900);
            }
            else if (N <= 99999)
            {
                int tmp = N - 9999;
                Console.WriteLine(9 + 900 + tmp);
            }
            else
            {
                Console.WriteLine(9 + 900 + 90000);
            }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define ll   long long
#define pi pair<ll,ll>

ll a[300000];

int main()
{
    IO;
    ll i, j, k = 0, n, g, r, mod=1e9+7, l, t, mn;
        cin>>i>>j>>k>>l;
        cout<<max(max(i*l,j*l),max(i*k,j*k))<<endl;

        return 0;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {
	private	static	BufferedReader	br = null;

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

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]	aNum = null;

		while((aNum = parseNum()) != null) {
			Arrays.sort(aNum);
			for (int n = aNum.length - 1; n >= 0; n--) {
				if (n == 0) {
					System.out.println(aNum[n]);
				}
				else {
					System.out.printf("%d ", aNum[n]);
				}
			}
		}
	}

	private static int[] parseNum() {
		int[]	aNum = null;
		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					String[]	aTmp = line.split(" ");
					aNum = new int[aTmp.length];
					for (int n = 0; n < aNum.length; n++) {
						aNum[n] = Integer.parseInt(aTmp[n]);
					}
				}
			}
		}
		catch (IOException e) {}

		return aNum;
	}
}

Measured memory_bytes: 16972
#include<bits/stdc++.h>
using namespace std;
#define RI register int
const int N=105;
char mp[N][N];
int f[2][N][N][N],a[N][N],n,m,sx,sy,ans;
int gets(int x1,int y1,int x2,int y2)
	{return a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];}
int main()
{
	scanf("%d%d",&n,&m);
	for(RI i=1;i<=n;++i) {
		scanf("%s",mp[i]+1);
		for(RI j=1;j<=m;++j) {
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(mp[i][j]=='o');
			if(mp[i][j]=='E') sx=i,sy=j;
		}
	}
	for(RI x1=0,t=0;x1<sx;++x1,t^=1)
	  for(RI y1=0;y1<sy;++y1)
	    for(RI x2=0;x2<=n-sx;++x2)
	      for(RI y2=0;y2<=m-sy;++y2) {
	      	if(x1&&sx-x1>x2)
	      		f[t][y1][x2][y2]=max(f[t][y1][x2][y2],f[t^1][y1][x2][y2]+
	      			gets(sx-x1,max(sy-y1,y2+1),sx-x1,min(sy+y2,m-y1)));
	      	if(y1&&sy-y1>y2)
	      		f[t][y1][x2][y2]=max(f[t][y1][x2][y2],f[t][y1-1][x2][y2]+
	      			gets(max(sx-x1,x2+1),sy-y1,min(sx+x2,n-x1),sy-y1));
	      	if(x2<n&&sx+x2<=n-x1)
	      		f[t][y1][x2][y2]=max(f[t][y1][x2][y2],f[t][y1][x2-1][y2]+
	      			gets(sx+x2,max(sy-y1,y2+1),sx+x2,min(sy+y2,m-y1)));
	      	if(y2<m&&sy+y2<=m-y1)
	      		f[t][y1][x2][y2]=max(f[t][y1][x2][y2],f[t][y1][x2][y2-1]+
	      			gets(max(sx-x1,x2+1),sy+y2,min(sx+x2,n-x1),sy+y2));
	      	ans=max(ans,f[t][y1][x2][y2]);
	      }
	printf("%d\n",ans); 
	return 0;
}

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

const int MAX_N = 2e5 + 5;
int A[MAX_N], X[MAX_N];

int main(){
    int n; cin >> n;
    for(int i=0;i<n;i++){
        cin >> X[i]; A[i] = X[i];
    }

    sort(A, A+n);
    
    int mn = A[n/2-1], mx = A[n/2];
    for(int i=0;i<n;i++){
        if(X[i]<=mn) cout << mx << endl;
        else cout << mn << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cassert>
#include<map>
#include<sstream>
using namespace std;
typedef long long ll;

ll getbit(char a){
  if (isupper(a))a-='A'+26;
  else if (islower(a))a-='a';
  else assert(false);
  return (1LL<<(int)a);
}

bool solve(string &in){
  for(int i=0;i<in.size();i++){
    if (in[i] == '|')in[i]=' ';
  }
  stringstream sin(in);
  string tmp;
  while(sin>>tmp){
    int p=0;
    assert(tmp[p] == '(');
    p++;
    bool isok=true;
    ll neg=0,pos=0;
    while(p < tmp.size()){
      if (tmp[p] == '~'){
	p++;
	neg|=getbit(tmp[p]);
	p++;
      }else {
	pos|=getbit(tmp[p]);
	p++;
      }
      assert(tmp[p] == '&' || tmp[p] == ')');
      p++;
    }
    if ((neg&pos) == 0)return true;
  }
  return false;
}

main(){
  string in;
  while(cin>>in){
    if (in == "#")break;
    cout << (solve(in)?"yes":"no") << endl;
  }
  return false;
}

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

int main()
{
    long double a,ans;
    
    while(cin >> a){
        ans = a;
        for(int i = 1; i < 10; ++i){
            if(i % 2){
                a *= 2;
            } else {
                a /= 3;
            }
            ans += a;
        }
        cout << setprecision(10) << ans << endl;
    }

}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll              long long int
#define vll             vector<ll>
#define vs              vector <string>                                    
#define mll             map<ll,ll>
#define pll             pair<ll, ll>
#define vpll            vector < pair<ll,ll> >
#define itr             vll::iterator
#define all(c)          c.begin(),c.end()
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define pb              push_back
#define mb              make_pair
#define ff              first
#define ss              second
#define max3(a,b,c)     max(max(a,b),c)                                    
#define min3(a,b,c)     min(min(a,b),c)  
#define mod             1000000007
#define inf             1000000000000000001
#define from(i, n)      for(__typeof(n) i = 0; i <  n; ++i)
#define fromj(i, j, n)  for(__typeof(n) i = j; i <  n; ++i)
#define printv(v)       from(i,v.size())cout<<v[i]<<" ";cout<<"\n";
#define w(x)            int x; cin>>x; while(x--)
 
using namespace std;
using namespace __gnu_pbds; 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}
 
bool func(const pll &a, const pll &b){
    if(a.ss==b.ss)return a.ff<b.ff;
    return a.ss < b.ss;
}
 
typedef tree<int, null_type, less<int >, rb_tree_tag, 
             tree_order_statistics_node_update> pbds; 
 
int main(){
    c_p_c();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s,t,ans="";
    cin>>s>>t;
    vector<vll > a(s.size()+1,vll(t.size()+1,0));
    /*from(i,s.size()+1)a[i][0]="";
    from(i,t.size()+1)a[0][i]="";*/
    for(ll i=1;i<s.size()+1;i++){
        for(ll j=1;j<t.size()+1;j++){
            if(s[i-1]==t[j-1]){
                //ans = ans+s[i-1];
                a[i][j]=a[i-1][j-1]+1;
            }    
            else if(a[i][j-1]>a[i-1][j])a[i][j]=a[i][j-1];
            else a[i][j]=a[i-1][j];
        }
    }
    ll i=s.size(),j=t.size();
    while(i>=1 && j>=1){
        if(s[i-1]==t[j-1]){
            ans=s[i-1]+ans;
            i--;j--;
        }   
        else if(a[i][j-1]>a[i-1][j])j--;
        else i--;
    }
    cout<<ans;
}    

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int cnt = count(begin(s), end(s), 'E') - (s[0] == 'E');
    int mi = cnt;
    for (int i = 0; i + 1 < n; i++) {
        cnt += (s[i] == 'W') - (s[i + 1] == 'E');
        mi = min(mi, cnt);
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 900
#coding:utf-8

class UnionFind:
    def __init__(self,n):
        self.parent=[i for i in range(n+1)]
        self.rank=[0]*(n+1)
    def find(self,x):
        if self.parent[x] == x: # if x is x`s root
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def is_same_tree(self,x,y):
        return self.find(x) == self.find(y) 
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        
def main():
    n=list(map(int,input().split()))
    union=UnionFind(n[0])
    friends=[]
    question=[]
    for i in range(n[1]):
        a=tuple(map(int,input().split()))
        friends.append(a)
    for i in friends:
        union.union(i[0],i[1])
    m=int(input())
    for i in range(m):
        b=tuple(map(int,input().split()))
        question.append(b)
    for i in question:
        if union.find(i[0]) == union.find(i[1]):
            print("yes")
        else:
            print("no")
if __name__ == "__main__":
    main()


Measured memory_bytes: 24988