akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a,T b){for(T i=a;i!=b;++i)cout<<*i<<" ";cout<<endl;}
template<class T> void chmin(T &t,T f){if(t>f)t=f;}
template<class T> void chmax(T &t,T f){if(t<f)t=f;}
int in(){int x;scanf("%d",&x);return x;}

int yoko[6][6],tate[6][6];

int state;
pint pos;


int main(){
	int i,j;
	for(i=0;i<4;i++){
		for(j=0;j<4;j++)yoko[i][j]=getchar()-'0';
		getchar();
		for(j=0;j<5;j++)tate[i][j]=getchar()-'0';
		getchar();
	}
	for(j=0;j<4;j++)yoko[4][j]=getchar()-'0';
	cout<<"R";
//cout<<endl;
	pos.first=1;
	pos.second=0;
	state=0;
/*	for(i=0;i<4;i++){
		for(j=0;j<4;j++)cout<<yoko[i][j];
		cout<<endl;
		for(j=0;j<5;j++)cout<<tate[i][j];
		cout<<endl;
	}
	for(j=0;j<4;j++)cout<<yoko[4][j];
	cout<<endl;
*/	
	
	while(pos.first!=0||pos.second!=0){
//cout<<pos.first<<" "<<pos.second<<endl;
		switch(state){
		case 0:
			if(pos.second!=0&&tate[pos.second-1][pos.first]==1){
				pos.second--;
				state=1;
			}else if(pos.first!=4&&yoko[pos.second][pos.first]==1){
				pos.first++;
				state=0;
			}else if(pos.second!=4&&tate[pos.second][pos.first]==1){
				pos.second++;
				state=3;
			}else{
				pos.first--;
				state=2;
			}
		break;
		case 1:
			if(pos.first!=0&&yoko[pos.second][pos.first-1]==1){
				pos.first--;
				state=2;	
			}else if(pos.second!=0&&tate[pos.second-1][pos.first]==1){
				pos.second--;
				state=1;
			}else if(pos.first!=4&&yoko[pos.second][pos.first]==1){
				pos.first++;
				state=0;
			}else{
				pos.second++;
				state=3;
			}
		break;
		case 2:
			if(pos.second!=4&&tate[pos.second][pos.first]==1){
				pos.second++;
				state=3;
			}else if(pos.first!=0&&yoko[pos.second][pos.first-1]==1){
				pos.first--;
				state=2;
			}else if(pos.second!=0&&tate[pos.second-1][pos.first]==1){
				pos.second--;
				state=1;
			}else{
				pos.first++;
				state=0;
			}
		break;
		case 3:
			if(pos.first!=4&&yoko[pos.second][pos.first]==1){
				pos.first++;
				state=0;
			}else if(pos.second!=4&&tate[pos.second][pos.first]==1){
				pos.second++;
				state=3;
			}else if(pos.first!=0&&yoko[pos.second][pos.first-1]==1){
				pos.first--;
				state=2;
			}else{
				pos.second--;
				state=1;
			}
		break;
		default: cout<<"hoge"<<endl;
		break;
		}
		if(state==0)cout<<"R";
		if(state==1)cout<<"U";
		if(state==2)cout<<"L";
		if(state==3)cout<<"D";
	}
	cout<<endl;


	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    total = sum(A)
    c = 0
    for a in A:
        c += a * 4 * M >= total

    if c >= M:
        print(Yes)
    else:
        print(No)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9988
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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

	int n;
	cin >> n;
	vector<P> ab(n), cd(n);
	for (int i = 0; i < n; i++) {
		cin >> ab[i].second >> ab[i].first;
	}
	for (int i = 0; i < n; i++) {
		cin >> cd[i].first >> cd[i].second;
	}

	sort(cd.begin(), cd.end());
	sort(ab.rbegin(), ab.rend());

	vector<bool> used(n, false);
	int ans = 0;

	for (int i = 0; i < n; i++) {
		int bx = cd[i].first;
		int by = cd[i].second;
		for (int j = 0; j < n; j++) {
			if (used[j]) continue;
			int rx = ab[j].second;
			int ry = ab[j].first;
			if (rx < bx && ry < by) {
				used[j] = true;
				ans++;
				break;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 888
function Main(input){
  input = input.split(' ');
  var a = input[0];
  var b = input[1];
  var c = input[2];

  var a_str_last = a.substr(-1,1);
  var b_str = b.substr(0,1);
  var b_str_last = b.substr(-1,1);
  var c_str = c.substr(0,1);

  if(a_str_last === b_str && b_str_last === c_str) {
      console.log('YES');
  } else {
      console.log('NO');
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		if (r < 1200) {
			System.out.println("ABC");
		}else if (r < 2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}
	}
}


Measured memory_bytes: 35604
n = int(input())
i = input()

i = i.split()
for item in range(len(i)):
    i[item] = int(i[item])

totn = 0
totp = 0

countp = 0
countn = 0

for x in range(len(i)):
    totp += i[x]
    totn += i[x]
    
    if x == 0:
        if totp == 0:   
            totn = -1
            countn = 1

            totp = 1
            countp = 1
            
        elif totp < 0:
            countp = abs(totp) + 1
            totp = 1

        elif totp > 0:
            countn = abs(totn) + 1
            totn = -1

    elif x %2 == 1:
        if totn == 0:
            countn += 1
            totn = 1
        elif totn < 0:
            countn += abs(totn) + 1
            totn = 1

        if totp == 0:
            countp += 1
            totp = -1
        elif totp > 0:
            countp += abs(totp) + 1
            totp = -1

    elif x %2 == 0:
        if totn == 0:
            countn += 1
            totn = -1
        elif totn > 0:
            countn += abs(totn) + 1
            totn = -1

        if totp == 0:
            countp += 1
            totp = 1
        elif totp < 0:
            countp += abs(totp) + 1
            totp = 1
    '''print('totn', totn)
    print('countn', countn)
    print('totp', totp)
    print('countp', countp) '''   
count = min(countn, countp)
print(count)


Measured memory_bytes: 11516
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <iomanip>
#define   mod  998244353 
#define   int  long long  
#define   ld   long double 
#define   pb   push_back 
#define   vi  vector<int>  
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   sz(x)  (int)x.size() 
#define   all(a) (a.begin(),a.end()) 
#define   ff   first 
#define   ss   second 
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

inline void solve(){ 
    ld  w, h, x, y; 
    cin >> w >> h >> x >> y ; 
    ld area=w*h;
    if (((int)area&1) or (w/2 != x) or (h/2 != y)){
        cout<< setprecision(9)<<fixed;
        cout << (area/2.0) << " 0" << endl;
    }
    else {
        cout << (area/2.0) << " 1" << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3696
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
 using namespace std;

 constexpr double EPS = 1e-9;

 struct point {
	 double x, y;
	 explicit point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {}
	 point(const point &p):x(p.x), y(p.y) {}

	 point operator+ (const point &p) const {
		 return point(x + p.x, y + p.y);
	 }

	 point operator- (const point &p) const {
		 return point(x - p.x, y - p.y);
	 }

	 point operator* (double s) const {
		 return point(x * s, y * s);
	 }

	 point operator* (const point &p) const {
		 return point(x * p.x - y * p.y, x * p.y + y * p.x);
	 }

	 point operator/ (double s) const {
		 return point(x / s, y / s);
	 }

	 bool operator< (const point &p) const {
		 return x + EPS < p.x || (abs(x - p.x) < EPS && y + EPS < p.y);
	 }

	 bool operator== (const point &p) const {
		 return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	 }
 };

 double norm(const point &p) {
	 return p.x * p.x + p.y * p.y;
 }

 double abs(const point &p) {
	 return sqrt(norm(p));
 }

 double dot(const point &a, const point &b) {
	 return a.x * b.x + a.y * b.y;
 }

 double cross(const point &a, const point &b) {
	 return a.x * b.y - a.y * b.x;
 }

 struct segment {
	 point a, b;
	 segment(const point &a_, const point &b_):a(a_), b(b_){}
 };

 struct line {
	 point a, b;
	 line(const point &a_, const point &b_):a(a_), b(b_){}
 };

 int ccw(const point &a, point b, point c) {
	 b = b - a;
	 c = c - a;
	 const double tmp = cross(b, c);
	 if(tmp > EPS) return 1; // ccw
	 if(tmp < -EPS) return -1; // cw
	 if(dot(b, c) < 0) return 2; // c, a, b 順に一直線上
	 if(norm(b) < norm(c)) return -2; // a, b, c 順に一直線上
	 return 0; //a, c, b 順で一直線上
 }

 bool intersect(const segment &s, const segment &t) {
	 return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0
		 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
 }

 double dist(const line &l, const point &p) {
	 return abs(cross(l.b - l.a, p - l.a)) / abs(l.b - l.a);
 }

 double dist(const segment &s, const point &p) {
	 if(dot(s.b - s.a, p - s.a) < 0) return abs(p - s.a);
	 if(dot(s.a - s.b, p - s.b) < 0) return abs(p - s.b);
	 return dist(line(s.a, s.b), p);
 }

 double dist(const segment &s, const segment &t) {
	 if(intersect(s, t)) return 0;
	 return min({dist(s, t.a), dist(s, t.b), dist(t, s.a), dist(t, s.b)});
 }

vector<point> input_polylines(const point &s, const point &t) {
	 int n;
	 cin >> n;

	 vector<point> res{s};
	 res.reserve(n + 2);

	 for(int i = 0; i < n; ++i) {
		 int x, y;
		 cin >> x >> y;
		 res.emplace_back(x, y);
	 }

	 res.emplace_back(t);

	 return res;
 }

 int main() {
	 cin.tie(nullptr);
	 ios::sync_with_stdio(false);
	 cout.setf(ios::fixed);
	 cout.precision(10);

	 const vector<point> P1 = input_polylines(point(0, 0), point(1000, 0));
	 const vector<point> P2 = input_polylines(point(0, 1000), point(1000, 1000));

	 double ans = INT_MAX;
	 for(unsigned i = 1; i < P1.size(); ++i) {
		 for(unsigned j = 1; j < P2.size(); ++j) {
			 ans = min(ans, dist(segment(P1[i], P1[i - 1]), segment(P2[j], P2[j - 1])));
		 }
	 }

	 cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1276
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val (n, x) = longList()
    val ni = n.toInt()
    val m = Array(n.toInt() + 1) { 0L }
    fun create(l: Int): Long {
        if (l == 0) {
            return 1
        }
        if (m[l] > 0L) {
            return m[l]
        }
        return (create(l - 1) * 2 + 3).also {
            m[l] = it
        }
    }

    fun eatCount(n: Int, x: Long): Long {
        if (n < 0) {
            return 0L
        }
        val layer = create(n)
        if (x == layer) {
            return layer / 2 + 1
        }
        val center = layer / 2;
        return when {
            x <= center -> {
                eatCount(n - 1, x - 1)
            }
            x == center + 1 -> {
                return center / 2 + 1
            }
            else -> {
                eatCount(n - 1, center - 1) + eatCount(n - 1, x - center - 1) + 1
            }
        }
    }
    println(eatCount(ni, x).toString())
}


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

int cs(int h,int w){
  long long s1,s2,s3,S1,S2,S3;
  s1=(w/3)*h;
  s2=(w-w/3)*(h/2);
  s3=(w-w/3)*(h-h/2);
  S1=(w/3+1)*h;
  S2=(w-w/3-1)*(h/2);
  S3=(w-w/3-1)*(h-h/2);
  return min(max({s1,s2,s3})-min({s1,s2,s3}),max({S1,S2,S3})-min({S1,S2,S3}));
}

int main(){
  int h,w;
  cin>>h>>w;
  if(h%3==0||w%3==0){
     cout << 0 << endl;
     return 0;
  }
  cout << min({min(h,w),cs(h,w),cs(w,h)}) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int A;
  scanf("%d", &A);
  long long int arr[A], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < A; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

Measured memory_bytes: 2504
#include<bits/stdc++.h>
using namespace std;
#define ll              long long int
#define ull             unsigned long long int
#define mod             1000000007 
#define pb              push_back
#define mp              make_pair
#define count_1(n)      __builtin_popcountll(n) //set bits
#define fr              first
#define sc              second

bool isPrime(ll n) {

  if (n == 1) {
    return false;
  }

  for (ll i = 2; i*i <=n; i++) {
    if (n % i == 0) return false;
  }

  return true;
}

 
   
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     
    x = x % p;  
                
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 

int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    return -1; 
} 



int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,f=0;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<=n-3;i++){
        if(a[i]==b[i] && a[i+1]==b[i+1]&& a[i+2]==b[i+2])
            f=1;
    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 3644
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  uf.Unite(a,b)
s = set()
for i in range(n):
  s.add(uf.Find_Root(i))
print(len(s)-1)

Measured memory_bytes: 81400
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	int n = 3;
	auto c = mat(int, n, n, 0);
	rep(i, n)rep(j, n)cin >> c[i][j];
	vector<int>si(n, 0);
	vector<int>sj(n, 0);
	rep(i, n) {
		rep(j, n) {
			si[i] += c[i][j];
		}
	}
	rep(j, n)rep(i, n)sj[j] += c[i][j];
	bool condi = false;
	int lim = 100;
	int sl2 = si[0] - si[1];
	int sl3 = si[1] - si[2];
	[&] {
		rep(a1, lim + 1)rep(a2, lim + 1) {

			if (sl3 % 3 == 0) {

				int a3 = a2 - (int)(sl3 / 3);
				if (sl2 == 3 * (a1 - a2) && a3 >= 0) {
					condi = true;
					return;
				}
			}


		}
	}();
	bool condj = false;
	int sc2 = sj[0] - sj[1];
	int sc3 = sj[1] - sj[2];
	[&] {
		rep(b1, lim + 1)rep(b2, lim + 1) {

			if (sc3 % 3 == 0) {

				int b3 = b2 - (int)(sc3 / 3);
				if (sc2 == 3 * (b1 - b2) && b3 >= 0) {
					condj = true;
					return;
				}
			}


		}
	}();
	if (condi&&condj) cout << "Yes";
	else cout << "No";











	return 0;
}





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

int main(){
	int x,temp,top=1;

	cin >>x;
	if(x==1)cout<<1<<endl;
	else{
		for(int i=2;i<x;i++){
			for(temp=i*i;temp<=x;temp*=i){
				if(top<temp)top=temp;
			}
		}
		cout<<top<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    a = i_list()

    one = 0
    b = []
    for i in a:
        if i %2 == 0:
            one += 1
            b.append(i//2)
    two = 0
    for i in b:
        if i % 2 == 0:
            two += 1
    zero = n - one
    one = n - zero - two
    if zero <= two or one == 0 and zero - two == 1:
        print("Yes")
    else:
        print("No")







if __name__=="__main__":
    main()


Measured memory_bytes: 84528
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- fmap (map read . words) getLine :: IO [Int]
  print $ solve as

solve as = go $ IntSet.findMin aset
  where
    aset = IntSet.fromList as
    f m = IntSet.foldl' (\m' a -> if a `mod` m' == 0 then m' else a `mod` m') m aset
    go m = let m' = f m
      in if m' == m
         then m
         else go m'


Measured memory_bytes: 51580
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > X(N);
  std::vector<int > X_orig(N);
  for (int i=0; i<N; i++){
    scanf("%d", &X[i]);
    X_orig[i]=X[i];
  }
  std::sort(X.begin(), X.end());
  int middle1 = N/2-1;
  int middle2 = N/2;
  for (int i=0; i<N; i++){
    if (X_orig[i]<=X[middle1]){
      printf("%d\n", X[middle2]);
    } else {
      printf("%d\n", X[middle1]);
    }
  }
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll a[maxn*2];
vector<int>ans;
ll b[maxn*2];
int main()
{
     int n;
     cin>>n;
     for(int i=1;i<=n;i++)
        cin>>a[i],b[i]=a[i];
    for(int i=n;i>=1;i--)
    {
        ll re=0;
        for(int j=2;j*i<=n;j++)
        {
            re+=b[j*i];
        }
        re%=2;
        if(re!=a[i])
        {
            b[i]=1;
            ans.push_back(i);

        }
        else
        {
            b[i]=0;
        }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 4600
from heapq import heappop, heappush

N, M = map(int, input().split())
W = []
for i in range(N):
  a = list(map(int, input().split()))
  heappush(W, a)
  
ans = 0
C = []

for i in range(1,M+1):
  j = -i
  while W != [] and W[0][0] <= i:
    a,b = heappop(W)
    heappush(C,-b)
  if C != []:
    ans += -heappop(C)
print(ans)

Measured memory_bytes: 27888
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  int n;
  cin>>n;
  vector<ll> t(n);
  rep(i,n) cin>>t[i];
  if(n==1) cout<<t[0];
else{
  ll ans=lcm(t[0],t[1]);
  rep2(i,2,n) ans=lcm(ans,t[i]);
  cout<<ans;
}
return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

typedef long long   ll;
typedef long double ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f
const string YES = "Yes";
const string NO = "No";

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

bool solve(string N) {
  int res=0;
  rep(i, N.length())
    res += N[i]-'0';
  return res % 9 ? false : true;
}

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

  string N;
  cin >> N;

  auto ans = solve(N);
  cout << (ans ? YES : NO) << endl;

  return 0;
}


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

int N, W, D;
vector<pair<int, int> > interval;

int projection(int x, int y, int dx, int dy){
	int dist = 1000000000;
	int xx = x;
	int yy = y;
	if(dx > 0) dist = min(dist, W - x);
	if(dx < 0) dist = min(dist, x);
	if(dy > 0) dist = min(dist, D - y);
	if(dy < 0) dist = min(dist, y);
	x += dist * dx;
	y += dist * dy;
	int ret;
	if(x == 0) ret =  y;
	else if(y == D) ret = D + x;
	else if(x == W) ret =  D + W + (D - y);
	else ret =  D + W + D + (W - x);
	return ret;
}



int main(){
	cin >> N >> W >> D;
	for(int i = 0; i < N; i++){
		int x, y; char c;
		cin >> x >> y >> c;
		int s, e;
		if(c == 'N'){
			s = projection(x, y, -1, 1);
			e = projection(x, y, 1, 1);
		}else if(c == 'E'){
			s = projection(x, y,  1, 1);
			e = projection(x, y, 1, -1);
		}else if(c == 'S'){
			s = projection(x, y, 1, -1);
			e = projection(x, y, -1, -1);
		}else if(c == 'W'){
			s = projection(x, y, -1, -1);
			e = projection(x, y, -1, 1);
		}
		if(s > e) e += 2 * W + 2 * D;
		interval.push_back({e, s});
	}
	sort(interval.begin(), interval.end());

	int ans = 10000000;
	for(int i = 0; i < N; i++){
		int a1 = 1;
		int start = interval[i].first;
		int cur = start;
		//cout << "=======" << i << "===========" << endl;
		for(int j = 1; j < N; j++){
			int e = interval[i + j].first;
			int s = interval[i + j].second;
		//	printf("%d+%d (%d, %d) %d %d\n", i, j, s, e, cur, start);
			if(!(s <= cur && cur <= e)  && start + 2 * W + 2 * D > e ){
				a1 += 1;
				cur = e;
			}
		}
		//cout << "(" << a1 << ")" << endl;
		ans = min(ans, a1);
		int e = interval[i].first + 2 * W + 2 * D;
		int s = interval[i].second + 2 * W + 2 * D;
		interval.push_back({e, s});
	}
	cout << ans << endl;	
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define pb push_back
#define tp make_tuple
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
#define r0 return 0
#define pi acos(-1)
using namespace std;

int main()
{
    ll n,m,i,j,k,x,y,z,t;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll d,s;

    cin>>d>>t>>s;

    k=(d+s-1)/s;

    if(k<=t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3632
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b; cin >> a >> b;
    rep(i, 100000) {
        if((i*8)/100 == a && (i*10)/100 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int m = cin.NextInt();
        List<int>[] s = new List<int>[m];
        int[] p = new int[m];

        for (int i = 0; i < m; i++)
        {
            int k = cin.NextInt();
            s[i] = new List<int>();
            for (int j = 0; j < k; j++)
            {
                s[i].Add(cin.NextInt() - 1);
            }
        }
        for (int i = 0; i < m; i++)
        {
            p[i] = cin.NextInt();
        }

        int ans = 0;
        for (int i = 0; i < Math.Pow(2, n); i++)
        {
            bool ok = true;
            for (int j = 0; j < m; j++)
            {
                var patterns = s[j];
                int count = 0;
                foreach (var pattern in patterns)
                {
                    if ((i >> pattern & 1) == 1)
                    {
                        count++;
                    }

                }
                if (count % 2 != p[j] % 2)
                {
                    ok = false;
                }
            }
            if (ok)
            {
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13268
#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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
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(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007


int a[200002];
int sb[29][200002];

int main() {
	int n;
	int ret = 0;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &a[i]);
	REP(i, n) {
		int tmp;
		scanf("%d", &tmp);
		int mask = 1;
		REP(j, 29) {
			sb[j][i] = tmp & mask;
			mask <<= 1;
			mask |= 1;
		}
	}
	REP(i, 29)sort(sb[i], sb[i] + n);
	REP(i, n) {
		REP(j, 29) {
			int mask = 1 << j;
			int tmp = a[i] & (mask-1);
			int s = mask - tmp;
			int e = (mask << 1) - tmp;
			auto si = lower_bound(sb[j], sb[j] + n, s);
			auto ei = lower_bound(sb[j], sb[j] + n, e);
			auto diff = ei - si;
			ret ^= (((diff & 1) << j) & ((~a[i]) & mask)) ^ ((((n-diff) & 1) << j) & (a[i] & mask));
		}
	}
	cout << ret << endl;
	return 0;
}

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

int main() {
  	int a, b, c, temp;
	cin >> a >> b >> c;
  
  	// swapping a & b
  	temp = a;
  	a = b;
  	b = temp;
  
  	// swapping a & c
  	temp = a;
  	a = c;
  	c = temp;
  
  	cout << a << " " << b << " " << c << "\n";
}

Measured memory_bytes: 256
import sys

def main():
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    ans=0;
    for i in range(n):
        kl=min(a[i],b[i])
        b[i]-=kl
        ans+=kl
        kl=min(a[i+1],b[i])
        a[i+1]-=kl
        ans+=kl
    print(ans)
    return 0

if __name__ == "__main__":
    sys.exit(main())


Measured memory_bytes: 18624
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
map<ll,ll> mp;
const ll mod=1000000007;
int main(){
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
int ans=0;
for(int i=0;i<n-1;i++){
    int j=i;
    int cnt=0;
    while(j+1<n&&a.at(j)==a.at(j+1)){
        cnt++;
        j++;
    }
ans+=(cnt+1)/2;
i=j;
}
cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void)
{
  char s[1001],t[1001];
  int slen,tlen;
  int ans,miss;

  scanf("%s %s",s,t);

  slen = strlen(s);
  tlen = strlen(t);
  ans = tlen;
  for(int i=0;i<=slen-tlen;i++)
  {
    miss=0;
    for(int j=0;j<tlen;j++)
    {
      if(s[i+j]!=t[j]) miss++;
    }
    if(ans>miss) ans=miss;
  }

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

  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
using namespace std;
int main() {
 
 
    string str;

    int n;
    cin >> n;
    cin >> str;

    if (n >= str.length()) {
        cout << str << endl;
    }
    else {
        str = str.substr(0, n);

        str = str.append("...");
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N,D,a,x;
      cin >> N >> D;
      
      a = D * 2 +1;
      
      x = N / a;
        if (N % a != 0){
        	x = x + 1;
        }
          
      cout << x << endl;
    	
	}

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    while(true){
        val n = readLine()!!.toInt()
        if (n == 0) return
        repeat(n){
            val (m, e, j) = readLine()!!.trim().split(' ').map(String::toInt)
            println(
                    when{
                        m == 100 || e == 100 || j == 100 -> 'A'
                        m + e >= 180 -> 'A'
                        m + e + j >= 240 -> 'A'
                        m + e + j >= 210 -> 'B'
                        m + e + j >= 150 && (m >= 80 || e >= 80) -> 'B'
                        else -> 'C'
                    }
            )
        }
    }
}


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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        tokens = lines[0].split(" ")
        n = int(tokens[0])
        for i in range(n):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        tokens = lines[0].split(" ")
        n = int(tokens[0])

    ab_list = []
    for i in range(1, n+1):
        tokens = lines[i].split(" ")
        a = int(tokens[0])
        b = int(tokens[1])
        ab_list.append((a, b))

    return (n, ab_list)


def solve(n, ab_list):


    ab_list.sort(key = lambda e: e[1])

    sum = 0
    result = "Yes"
    for i in range(n):
        e = ab_list[i]
        sum = sum + e[0]
        if sum > e[1]:
            result = "No"
            break

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


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

int main() {
  int num[3];
  for (int i = 0; i < 3; i++) {
    cin >> num[i];
  }
  sort(num, num+3);

  cout << num[0]+num[1]+num[2]*10 << endl;

  return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

const int gx[] = { 1, 3, 5, 7, 8, 10, 12 };
const int gy[] = { 4, 6, 9, 11 };

int isX(int a);
int isY(int a);
int getG(int a);

int main(void)
{
  int x, y;

  scanf("%d %d", &x, &y);

  x = getG(x);
  y = getG(y);

  if (x == y) printf("Yes\n");
  else        printf("No\n");

  return 0;
}

int isX(int a)
{
  int i;
  for (i = 0; i < sizeof(gx) / sizeof(int); i++) {
    if (gx[i] == a) return 1;
  }
  return 0;
}

int isY(int a)
{
  int i;
  for (i = 0; i < sizeof(gy) / sizeof(int); i++) {
    if (gy[i] == a) return 1;
  }
  return 0;
}

int getG(int a)
{
  if (isX(a)) return 0;
  if (isY(a)) return 1;
  return 2;
}


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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 998244353;

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n ;cin >> n;
	int y = log2(n);
	int ans = pow(2 , y + 1) - 1;
	cout << ans;
}	



Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

#define sqr(x) ((x) * (x))

int main(void) {
	double a, b, c, z;
	double x1, x2, x3, y1, y2, y3;
	double S = 0;

	scanf("%lf,%lf", &x1, &y1);
	scanf("%lf,%lf", &x2, &y2);
	scanf("%lf,%lf", &x3, &y3);

	a = sqrt(sqr(x1 - x2) + sqr(y1 - y2));
	b = sqrt(sqr(x2 - x3) + sqr(y2 - y3));
	c = sqrt(sqr(x3 - x1) + sqr(y3 - y1));

	z = (a + b + c) / 2;
	S += sqrt(z * (z - a) * (z - b) * (z - c));

	x2 = x3; y2 = y3;
	a = c;

	while(scanf("%lf,%lf", &x3, &y3) != EOF) {
		b = sqrt(sqr(x2 - x3) + sqr(y2 - y3));
		c = sqrt(sqr(x3 - x1) + sqr(y3 - y1));

		z = (a + b + c) / 2;
		S += sqrt(z * (z - a) * (z - b) * (z - c));

		x2 = x3; y2 = y3;
		a = c;
	}

	printf("%lf\n", S);

	return 0;
}

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

using namespace std;

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n, x;
	cin >> n >> x;

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

	int d = 0, ans = 1;
	
	for(int i = 0; i < n; i++) {
		d += l[i];
		if(d <= x) ans++;
		else break;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;
ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}

int main(){	
	ll n,m;
	string s,t;
	cin>>n>>m>>s>>t;
	ll ans=gcd(n,m);
	for(ll i=0;i<ans;++i){

		if(s[i*(n/ans)]!=t[i*(m/ans)]){
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<lcm(n,m)<<endl;
	return 0;
}


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

typedef long long LL;

const int N = 2e6+7, M = 998244353;
LL fac[N], invfac[N];

LL power(LL a, LL p) {
    if (p==0)   return 1;
    LL ans = power(a, p/2);
    ans = (ans*ans)%M;
    if (p%2)    ans = (ans * a)%M;
    return ans;
}

void pre() {
    fac[0] = 1;
    for (int i=1; i<N; i++)
        fac[i] = (fac[i-1]*i)%M;

    invfac[N-1] = power(fac[N-1], M-2);
    for (int i=N-2; i>=0; i--)
        invfac[i] = (invfac[i+1] * (i+1))%M;
}

LL C(int n, int k) {
    if (k<0 || k>n) return 0;
    LL denom = (invfac[k]*invfac[n-k])%M;
    return (fac[n]*denom)%M;
}

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

    LL ans = 0;
    for (int i=0; i<=n && i<=m; i++) {
        LL choose = C(n, i);
        LL rem = 3*m - i;
        if (rem%2)  continue;
        rem/=2;

        LL ways = C(rem+n-1,n-1);
        LL bad = ((n-i)*C(rem-m-1+n-1,n-1) + i*C(rem-m+n-1, n-1))%M;

//        cout<<i<<" "<<ways<<" "<<bad<<endl;
        ways = (ways-bad+M)%M;

//        cout<<i<<" "<<ways<<endl;
        ans = (ans + ways*choose)%M;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 31488
#include<stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, A[N][N];
int C[N],B[N], D[N], e;

void dfs(int);

void dfs2();

int main(){
  int i, j, a, b, c;
  
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d", &a, &b);
    a--;
    for(j = 0; j < b; j++){
      scanf("%d", &c);
      c--;
      A[a][c] = 1;
    }
  }

  dfs2();

  return 0;
}

void dfs(int a){
  int b;
  C[a] = GRAY;
  B[a] = ++e;
  for(b = 0; b < n; b++){
    if(A[a][b] == 0) continue;
    if(C[b] == WHITE){
      dfs(b);
    }
  }
  C[a] = BLACK;
  D[a] = ++e;
}


void dfs2(){
  int i;
  for(i = 0; i < n; i++){
    C[i] = WHITE;
  }

  e = 0;
  for(i = 0; i < n; i++){
    if(C[i] == WHITE )
      dfs(i);
  }
  for(i = 0; i < n; i++){
    printf("%d %d %d\n", i+1, B[i], D[i]);
  }

}



Measured memory_bytes: 2112
#include<stdio.h>
#define N 100
int main(){
  int i,j,tmp;
  int number[N];
  int total;
  scanf("%d",&total);
  for(i=0;i<total;++i)
    scanf("%d",&number[i]);

  for(i=0;i<total;++i){
    tmp=number[i];
    j=i-1;
    while(j>=0 && number[j]>tmp){
      number[j+1]=number[j];
      --j;
    }
    number[j+1]=tmp;
    for(j=0;j<total;++j){
      if(j)
        printf(" ");
      printf("%d",number[j]);
    }
    printf("\n");
  }
  return 0;
}




Measured memory_bytes: 2068
import sys
N=input()
X=map(int, sys.stdin.readline().split())
X_MAX=max(X)

ans=float("inf")

for p in range(1,X_MAX+1):
    ans_kouho=0
    for x in X:
        ans_kouho+=(x-p)**2
    ans=min(ans,ans_kouho)    
print ans

Measured memory_bytes: 29420
import numpy as np
from math import *
temp = input()
[a, b, h, m] = [float(comp) for comp in temp.split()]
h_co = a * np.array([cos(2.0 * pi * (h+m/60.) / 12.),
                     sin(2.0 * pi * (h+m/60.) / 12.)])
m_co = b * np.array([cos(2.0 * pi * m / 60.), sin(2.0 * pi * m / 60.)])
ans = np.linalg.norm(h_co-m_co)
print(ans)

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

int main() {

  string s;
  cin >> s;
  
  string p;
  cin >> p;
  
  int ssize = s.size();
  int psize = p.size();
  int ans = 0;
  
  for (int start = 0; start < ssize; start++) {
      int count = 0;
      for (int i=0; i<psize; i++) {
          if (s.at( (start+i)%ssize ) == p.at(i)) {
              count++;
          }
      }
      if (count == psize) {
          ans = 1;
          break;
      }
  }
  
  if (ans == 1) {
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }

return 0;
}




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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e7 + 9, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


ll numDivisors[N];

void go(int tc){

    int n;  cin >> n;


    for(int i = 1;i <= n;i++){
        for(int j = i;j <= n;j += i){
            numDivisors[j]++;
        }
    }

    ll ans = 0;
    for(int i = 1;i <= n;i++){
        ans += i * numDivisors[i];
    }

    cout << ans;

}




int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

    int t = 1, tc = 1;//  cin >> t;
    while(t--)  go(tc++);

}

Measured memory_bytes: 81772
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
#define exist_in(list, value) (list.end() != std::find(all(list),value))
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }
//template<class T> bool exist_in(const T& c, const typename T::value_type& v) {	return (c.end() != std::find(c.begin(), c.end(), v));}

/*****/

void Main()
{
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		cout << "Possible";
	else
		cout << "Impossible";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256