akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
inline int read () {
	int num = 0;
	char c = ' ';
	bool flag = true;
	for (;c > '9' || c < '0';c = getchar())
		if (c == '-')
			flag = false;
	for (;c >= '0' && c <= '9';num = (num << 1) + (num << 3) + c - 48, c = getchar());
	return flag ? num : -num;
}
namespace INIT {
	const int maxn = 100020;
	int p, y, n, m;
	struct node {
		int id, p, y, x;
	};
	vector <node> P[maxn];
	void init () {
		n = read (); m = read ();
		for (int i = 1;i <= m;i ++) {
			p = read (), y = read ();
			P[p].push_back ((node) {i, p, y, 0});
		}
	}
} using namespace INIT;
namespace WORK {
	bool mycmp1 (node a, node b) {
		return a.y < b.y;
	}
	bool mycmp2 (node a, node b) {
		return a.id < b.id;
	}
	node city[maxn];
	int cnt = 0;
	void prework () {
		for (int i = 1;i <= n;i ++) 
			if (P[i].size ()) {
				sort (P[i].begin (), P[i].end (), mycmp1);
				for (int j = 0;j < P[i].size ();j ++) {
					P[i][j].x = j + 1;
					city[++ cnt] = P[i][j]; 
				}
			}
		sort (city + 1, city + 1 + cnt, mycmp2);
	}
	void print () {
		int c[10], top = 0;
		for (int i = 1;i <= cnt;i ++) {
			top = 0;
			while (city[i].p) {
				c[++ top] = city[i].p % 10;
				city[i].p /= 10;
			}
			for (int j = 6;j > top;j --)
				printf ("0");
			for (int j = top;j >= 1;j --)
				printf ("%d", c[j]);
			top = 0;
			while (city[i].x) {
				c[++ top] = city[i].x % 10;
				city[i].x /= 10;
			}
			for (int j = 6;j > top;j --)
				printf ("0");
			for (int j = top;j >= 1;j --)
				printf ("%d", c[j]);
			printf ("\n");
		}
	}
} using namespace WORK;
int main () {
	init ();
	prework ();
	print ();
	return 0;
}

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

int a[1001];
int main(){
	int n, d = 1e9;
	double ans = 0;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)scanf("%d", &a[i]);
	sort(a, a+n);
	
	for(int i = 0;i < n-3;i++)d = min(d, a[i+1]-a[i]);
	ans = max(ans, (double)(a[n-1]+a[n-2])/d);
	ans = max(ans, (double)(a[n-3]+a[n-4])/(a[n-1]-a[n-2]));
	ans = max(ans, (double)(a[n-1]+a[n-4])/(a[n-2]-a[n-3]));
	printf("%lf\n", ans);
	return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
// using Graph = vector<vector<int>>;

int H, W;
vector<string> fi;

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

int main() {
  cin >> H >> W;
  fi.resize(H);
  for (int i = 0; i < H; ++i) cin >> fi[i];
  int cnt = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (fi[i][j] == '#') cnt++;
    }
  }

  vector<vector<int> > dist(H, vector<int>(W, -1));
  using pint = pair<int, int>;
  queue<pint> que;
  que.push(pint(0, 0));

  // BFS
  while (!que.empty()) {
    auto cur = que.front();
    que.pop();
    for (int dir = 0; dir < 4; ++dir) {
      int nx = cur.first + dx[dir];
      int ny = cur.second + dy[dir];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (fi[nx][ny] == '#') continue;
      if (dist[nx][ny] == -1) {
        dist[nx][ny] = dist[cur.first][cur.second] + 1;
        que.push(pint(nx, ny));
      }
    }
  }
  if (dist[H - 1][W - 1] == -1)
    cout << -1 << endl;
  else
    cout << H * W - dist[H - 1][W - 1] - cnt - 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 2010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n,0),b(n,0);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[n-i-1];
    rep(i,n-1){
        a[i+1] += a[i];
        b[i+1] += b[i];
    }
    int ans = 0;
    rep(i,n) chmax(ans,a[i]+b[n-i-1]);
    PRINT(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(l,r)     ((l)+((r)-(l))/2) 

#define fo(i,a,b)    for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***

const int N = 1e6;


void solve()
{
    ll n;rd(n);
    if(n==1 or n==7){
        cout<<1<<endl;re;
    }   
    ll m = 1;
    ll ans = 7%n;
    fo(i,2,N){
        m*=10;m%=n;
        ans = (m*7+ans)%n;
        if(ans==0){
            cout<<i<<endl;re;
        }
    }
    cout<<-1<<endl;
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3636
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextFloat64(scanner)
	m := getNextFloat64(scanner)
	d := getNextFloat64(scanner)

	ans := (m - 1) * ((n - d) / (n * n))
	if d != 0 {
		ans *= 2
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 640
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  for (int &i : d)
  {
    cin >> i;
  }
  sort(d.begin(), d.end());
  int count = 1;
  for (int i = 1; i < n; i++)
  {
    if (d.at(i - 1) != d.at(i))
    {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import queue
import copy
import bisect#2分探索
from collections import deque #popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s): return sorted(range(len(s)), key=lambda k: s[k])

#mod = 10**9+7

#N = int(input())
S,W = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [inputl() for i in range(H)]
#q = queue.Queue() #q.put(i) #q.get() 
#q = queue.LifoQueue() #q.put(i) #q.get() 

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#w.sort(key=lambda x:x[1],reverse=True)  #二個目の要素で降順並び替え

#素数リスト
# n = 100
# primes = set(range(2, n+1))
# for i in range(2, int(n**0.5+1)):
#     primes.difference_update(range(i*2, n+1, i))
# primes=list(primes)

#bisect.bisect_left(a, 4)#aはソート済みである必要あり。aの中から4未満の位置を返す。rightだと以下
#bisect.insort_left(a, 4)#挿入

if S<=W:
    print('unsafe')
else:
    print('safe')

Measured memory_bytes: 74884
#include<unordered_set>
#include<set>
#include<deque>
#include<queue>
#include<map>

#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long int llint;
#define pub push_back
#define mp make_pair
#define fir first
#define sec second
#define res resize
#define mt make_tuple
const int big=((int)1<<30);
int main(void){
	int H,W,K,i,j,n,sx,sy,x,y,ka,sai=big;
	queue<tuple<int,int,int>> que;//x,y,回数
	vector<string> hey;
	vector<vector<bool>>ot;
	cin>>H>>W>>K;
	hey.resize(H);
	ot.resize(H);
	for(i=0;i<H;i++){cin>>hey[i];}
	for(i=0;i<H;i++){ ot[i].resize(W); for(j=0;j<W;j++){ if(hey[i][j]=='S'){ sx=i;sy=j; } } }
	que.push(mt(sx,sy,K));
	while(!que.empty()){
		x=get<0>(que.front());
		y=get<1>(que.front());
		ka=get<2>(que.front());
		que.pop();
		if(ka==-1){break;}
		if(ot[x][y]){continue; }
		sai=min(sai,min(min(x,H-x-1),min(y,W-y-1)));
		if(sai==0){ break; }
		if(hey[x+1][y]!='#'){que.push(mt(x+1,y,ka-1));}
		if(hey[x-1][y]!='#'){que.push(mt(x-1,y,ka-1));}
		if(hey[x][y+1]!='#'){que.push(mt(x,y+1,ka-1));}
		if(hey[x][y-1]!='#'){que.push(mt(x,y-1,ka-1));}
		ot[x][y]=true;
	}
	
	cout<<(sai+K-1)/K+1<<endl;
	return 0;
}


Measured memory_bytes: 1280
fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut k = read::<u64>();

    for c in s {
        let i = (c as i32 - 48) as u64;
        if i == 1 {
            k -= i;
            if k == 0 {
                println!("{}", i);
                break;
            }
        } else {
            println!("{}", i);
            break;
        }
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
N,K=map(int,input().split())
TD=[[int(j) for j in input().split()] for i in range(N)]
TD=sorted(TD,key=lambda x:-x[1])
point=0
stack=[]
kind=set()
for t,d in TD[:K]:
    point+=d
    if t in kind:stack.append(d)
    else:kind.add(t)
point=point+len(kind)**2
ans=point
for t,d in TD[K:]:
    if not stack:break
    if not t in kind:
        point+=d-stack.pop()+2*len(kind)+1
        kind.add(t)
        ans=max(ans,point)
print(ans)

Measured memory_bytes: 26892
using System;

class Program{
    class Card{
        public int value;
        public char suit;
        public Card(char suit, int value){
            this.suit=suit;
            this.value=value;
        }
    }

    static void Swap(Card[] A, int a, int b){
        var tmp=A[a];
        A[a]=A[b];
        A[b]=tmp;
    }

    static int Partition(Card[] A, int p, int r){
        var x=A[r-1].value;
        var i=p-1;
        for(var j=p; j<r-1; j++){
            if(A[j].value<=x){
                i++;
                Swap(A, i, j);
            }
        }
        Swap(A, i+1, r-1);
        return i+1;
    }

    static void QuickSort(Card[] A, int p, int r){
        if(p+1<r){
            var q=Partition(A, p, r);
            QuickSort(A, p, q);
            QuickSort(A, q, r);
        }
    }

    static void Merge(Card[] A, int left, int mid, int right){
        var n1=mid-left;
        var n2=right-mid;
        var L=new Card[n1+1];
        var R=new Card[n2+1];
        for(var i=0; i<n1; i++){
            L[i]=A[left+i];
        }
        for(var i=0; i<n2; i++){
            R[i]=A[mid+i];
        }
        L[n1]=new Card('X', 1000*1000*1000+1);
        R[n2]=new Card('X', 1000*1000*1000+1);
        var l=0;
        var j=0;
        for(var k=left; k<right; k++){
            if(L[l].value<=R[j].value){
                A[k]=L[l];
                l++;
            } else{
                A[k]=R[j];
                j++;
            }
        }
    }

    static void MergeSort(Card[] A, int left, int right){
        if(left+1<right){
            var mid=(left+right)/2;
            MergeSort(A, left, mid);
            MergeSort(A, mid, right);
            Merge(A, left, mid, right);
        }
    }

    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        var A=new Card[n];
        var B=new Card[n];
        for(var i=0; i<n; i++){
            var s=Console.ReadLine().Split(' ');
            A[i]=new Card(s[0][0], int.Parse(s[1]));
            B[i]=new Card(s[0][0], int.Parse(s[1]));
        }

        QuickSort(A, 0, n);
        MergeSort(B, 0, n);
        var isStable=true;
        for(var i=0; i<n; i++){
            if(A[i].suit!=B[i].suit){
                isStable=false;
                break;
            }
        }

        var sout=new System.Text.StringBuilder();
        sout.Append(isStable ? "Stable\n" : "Not stable\n");
        for(var i=0; i<n; i++){
            sout.Append(A[i].suit+" "+A[i].value+"\n");
        }
        Console.Write(sout);
    }
}

Measured memory_bytes: 23584
s = gets.chomp.split("")
q = gets.chomp.to_i
head = []
tail = []
rev = 0
query = []

q.times do
    query << gets.chomp
end

query.each do |input|
    if input == "1"
        rev += 1
    else
        n, f, c = input.split(" ")
        if f == "1"
            if rev % 2 == 0
                head.unshift(c)
            else
                tail << c
            end
        else
            if rev % 2 == 0
                tail << c
            else
                head.unshift(c)
            end
        end
    end
end

if rev % 2 == 0
    puts (head + s + tail).join("")
else
    puts (head + s + tail).reverse.join("")
end

Measured memory_bytes: 52004
n = int( raw_input( ) )

mi = int( raw_input( ) )
profit = 0 - 1000000000

for i in range( n-1 ):
	num = int( raw_input( ) )
	
	diff = num - mi
	if profit < diff:
		profit = diff

	if num < mi:
		mi = num

print( profit )

Measured memory_bytes: 10520
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(10000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

from decimal import *

a,b,c = IL()
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
  print("Yes")
else:
  print("No")


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

string a,b,f,s;

int main()
{
	getline(cin,a);
	getline(cin,b);
	for(int i=0;i<a.size();i++)
		for(int j=i+1;j<a.size();j++)
		if (a[i]>a[j])
			swap(a[i],a[j]);
	for(int i=0;i<b.size();i++)
		for(int j=i+1;j<b.size();j++)
		if (b[i]<b[j])
			swap(b[i],b[j]);
	if (a<b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> d;

int main()
{
	ll n;
	ll ans;
	ll k = 0;
	ll abc = 0;
	ll arc = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		d.push_back(tmp);
	}
	
	sort(d.begin(), d.end());

	ans = d[d.size() / 2] - d[d.size() / 2 - 1];
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
import heapq as hp

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

q1 = []
S1 = 0
for p in P:
    hp.heappush(q1, p)
    S1 += p

while len(q1) > X:
    p = hp.heappop(q1)
    S1 -= p

q2 = []
S2 = 0
for q in Q:
    hp.heappush(q2, q)
    S2 += q

while len(q2) > Y:
    p = hp.heappop(q2)
    S2 -= p


tmp = S1 + S2
ans = S1 + S2
R.sort(reverse=True)
for r in R:
    p1 = hp.heappop(q1)
    p2 = hp.heappop(q2)
    if p1 <= p2:
        if r >= p1:
            tmp += r - p1
            ans = max(ans, tmp)
            hp.heappush(q1, r)
            hp.heappush(q2, p2)
        else:
            break
    else:
        if r >= p2:
            tmp += r - p2
            ans = max(ans, tmp)
            hp.heappush(q1, p1)
            hp.heappush(q2, r)
        else:
            break

print(ans)

Measured memory_bytes: 116176
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int x[123],y[123],h[123];
int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin>>n;
    int i,j,k;
    int remem=-1;
    rep(i,n){
    	cin>>x[i]>>y[i]>>h[i];
    	if(h[i]!=0)
    		remem=i;
    }
    int H,flag=0;
    swap(x[0],x[remem]);
    swap(y[0],y[remem]);
    swap(h[0],h[remem]);
    rep(i,101){
    	rep(j,101){

    		flag=0;
    		H=h[0]+abs(x[0]-i)+abs(y[0]-j);
    		rep(k,n){
    			if(max(H-abs(x[k]-i)-abs(y[k]-j),0)!=h[k])
    				flag=1;
    		}
    		if(!flag){
    			cout<<i<<" "<<j<<" "<<H<<endl;
    			return 0;
    		}
    	}
    }
    cout<<"ass"<<endl;
    return 0;   
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a;
    int flg = 0;
    while(cin >> a){
        int cnt = 0;
        for(int i = 0; i < a.size()/2; i++){
            if(a[i] == a[a.size()-1-i])cnt++;
        }
        if(cnt == a.size()/2)flg++;
    }
    printf("%d\n",flg);
    return 0;
}

Measured memory_bytes: 1176
program ABC157_B
  integer::A(9),C(3,3)
  integer,dimension(:),allocatable::B
  read(5,*)A
  read(5,*)N
  allocate(B(N))
  read(5,*)B
  do I=1,N
     do J=1,9
        if(A(J)==B(I)) then
           A(J)=0
           exit
        end if
     end do
  end do
  C=reshape(A,(/3,3/))
  K=0
  if(C(1,1)+C(2,2)+C(3,3)==0 .or. C(3,1)+C(2,2)+C(3,1)==0) K=1
  do I=1,3
     if(sum(C(I,:))==0 .or. sum(C(:,I))==0) then
        K=1
        exit
     end if
  end do
  if(K==1) then
     write(6,*)'Yes'
  else
     write(6,*)'No'
  end if
end program ABC157_B

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

using namespace std;

void out(int a[], char c){
    for(int i=1; i<=13; i++){
        if(a[i]==0) printf("%c %d\n",c,i);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int S[14],H[14],C[14],D[14];
    for(int i=0; i<14; i++) S[i]=H[i]=C[i]=D[i]=0;
    
    int n; cin>>n;
    while(n--){
        char a; cin>>a;
        int x; cin>>x;
        switch(a){
            case 'S': S[x]=1; break;
            case 'H': H[x]=1; break;
            case 'C': C[x]=1; break;
            case 'D': D[x]=1; break;
        }
        
    }
    out(S,'S');
    out(H,'H');
    out(C,'C');
    out(D,'D');
    
    return 0;
    
}



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

int main(){
    int n;
    string stmp;
    string s[52];

    while(true){
        cin >> n;
        if(n == 0) break;

        int maxk = 0;
        for(int i=0;i<n;i++){
            cin >> stmp;
            string scode = "";
            scode += stmp[0];
            for(int j=1;j<stmp.length();j++){
                if(stmp[j-1] == 'a' || stmp[j-1] == 'i' || stmp[j-1] == 'u' || stmp[j-1] == 'e' || stmp[j-1] == 'o'){
                    scode += stmp[j];
                }
            }
            s[i] = scode;
            maxk = max(maxk, (int)scode.length());
        }

        for(int k = 1;k<=maxk;k++){
            set<string> stringset;
            for(int i=0;i<n;i++){
                stringset.insert(s[i].substr(0, k));
            }
            if(stringset.size() == n){
                cout << k << "\n";
                break;
            }
            else{
                if(k == maxk){
                    cout << -1 << "\n";
                }
            }
        }

    }

    return 0;
}


Measured memory_bytes: 3180
/*
Code By: Sai Harsha K
 */

#include <bits/stdc++.h>
using namespace std;
#define lli long long int

int main() {
#ifndef ONLINE_JUDGE
  // these lines to be executed in local machine not online judge
  // get input
  freopen("input.txt", "r", stdin);
  // put output
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);

  // solution
  int t = 1;
  while(t--) {
    int n, k;
    cin>>n>>k;
    int a[n];
    for(int i = 0; i < n; i++) {
      cin>>a[i];
    }
    int dp[n];// 0 index
    memset(dp, 0x3f, sizeof(dp)); // some large number
    // base case
    dp[0] = 0;
    // populate dp
    for(int i = 1; i < n; i++) {
      for(int j = i - 1; j >= 0 && j >= i - k; j--) { // check prev k steps
        dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
      }
    }
    cout<<dp[n-1];
  }

  return 0;
}


Measured memory_bytes: 4428
s = input()
z = []
last = None
for c in s :
    if last == c :
        z[-1] += 1
    else :
        last = c
        z.append(1)
a = 0
flag = False
for v in z :
    if flag :
        a += (v*2+2)//3
        if v%3 == 0 :
            flag = True
        else :
            flag = False
    else :
        a += (v*2+1)//3
        if v%3 == 2 :
            flag = True
        else :
            flag = False
print(a)

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

int days[2][12]={
	{31,28,31,30,31,30,31,31,30,31,30,31},
	{31,29,31,30,31,30,31,31,30,31,30,31},
};

ll cnd[7];

int is_uruu(ll y,int m=-1,int d=-1){
	if(y%400LL==0LL)return 1;
	if(y%100LL==0LL)return 0;
	if(y%4LL==0LL)return 1;
	return 0;
}

ll calc_period(int d){
	ll ans=0;
	for(int i=1;i<=400;i++){
		for(int j=0;j<12;j++){
			int v=is_uruu(i);
			for(int k=1;k<=days[v][j];k++){
				if(k==13 && d==5){
					ans++;
				}
				d=(d+1)%7;
			}
		}
	}
	return ans;
}

void calc(){
	for(int i=0;i<7;i++){
		cnd[i]=calc_period(i);
	}
}

bool big(ll Y1,ll M1,ll D1,ll Y2,ll M2,ll D2){
	if(Y1<Y2)return true;
	if(Y1>Y2)return false;
	if(M1<M2)return true;
	if(M1>M2)return false;
	if(D1<D2)return true;
	if(D1>D2)return false;
	return true;
}

bool same(ll Y1,ll M1,ll D1,ll Y2,ll M2,ll D2){
	if(Y1!=Y2)return false;
	if(M1!=M2)return false;
	if(D1!=D2)return false;
	return true;
}

int is_day(ll Y1,ll M1,ll D1){
	Y1%=400LL;
	if(Y1==0LL)Y1+=400;
	ll Y2=15,M2=3,D2=15;
	if(big(Y1,M1,D1,Y2,M2,D2)){
		int cnt=0;
		while(!same(Y1,M1,D1,Y2,M2,D2)){
			//printf("uruu%d %lld %lld %lld\n",cnt,Y1,M1,D1);
			D1++;
			cnt++;
			int v=is_uruu(Y1);
			if(days[v][M1-1]<D1){
				D1=1;
				M1++;
			}
			if(M1==13){
				M1=1;
				Y1++;
			}
		}
		if(cnt%7==0)return 0;
		return (7-cnt%7);
	}else{
		int cnt=0;
		swap(Y1,Y2);
		swap(M1,M2);
		swap(D1,D2);
		while(!same(Y1,M1,D1,Y2,M2,D2)){
			D1++;
			cnt++;
			int v=is_uruu(Y1,M1,D1);
			if(days[v][M1-1]<D1){
				D1=1;
				M1++;
			}
			if(M1==13){
				M1=1;
				Y1++;
			}
		}
		return cnt%7;
	}
}


int main(void){
	ll Y1,Y2,M1,M2,D1,D2;
	scanf("%lld%lld%lld%lld%lld%lld",&Y1,&M1,&D1,&Y2,&M2,&D2);
	calc();
	int s=is_day(Y1,M1,D1);
	ll ans=0;
	if((Y1/400LL)<(Y2/400LL)){
		while(Y1%400LL!=1 || M1!=1 || D1!=1){
			if(D1==13 && s==5)ans++;
			D1++;
			s=(s+1)%7;
			int v=is_uruu(Y1,M1,D1);
			if(days[v][M1-1]<D1){
				D1=1;
				M1++;
			}
			if(M1==13){
				M1=1;
				Y1++;
			}
		}
		//printf("ok\n");
		ll loop=(Y2-Y1)/400LL;
		ans+=loop*cnd[s];
		Y2%=400LL;
		Y1%=400LL;
		if(Y2==0LL)Y2+=400LL;
	}
	//printf("ok\n");
	//printf("%lld %lld %lld %lld %lld %lld\n",Y1,M1,D1,Y2,M2,D2);
	//printf("%lld %lld %lld %lld %lld %lld\n",Y1,M1,D1,Y2,M2,D2);
	while(!same(Y1,M1,D1,Y2,M2,D2)){
		if(D1==13 && s==5)ans++;
		D1++;
		s=(s+1)%7;
		int v=is_uruu(Y1,M1,D1);
		if(days[v][M1-1]<D1){
			D1=1;
			M1++;
		}
		if(M1==13){
			M1=1;
			Y1++;
		}
	}
	if(D1==13 && s==5)ans++;
	printf("%lld\n",ans);
	return 0;
}



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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    priority_queue<int, std::vector<int>, std::greater<int>> q;
    q.push(a);
    q.push(b);
    q.push(c);

    while (!q.empty())
    {
        cout << q.top();
        q.pop();
        if (!q.empty())
        {
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		int c = gcd(A,B);
		int temp = c;
		while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		}
		System.out.println(temp+1);
		sc.close();

	}
	static int gcd(int m,int n) {
		if (m<n) {
			return gcd(n,m);
		}
		if (n==0) {
			return m;
		}
		return gcd(n,m%n);
	}
}


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

const char *suits = "SHCD";

int c2i(char c)
{
    int i = 0;
    for(const char *s = suits; *s != 0; s++, i++)
    {
        if(*s == c)
        {
            return i;
        }
    }
    return -1;
}

const char i2c(int i)
{
    return suits[i];
}

int main()
{
    const int SUIT_SIZE = 4;
    const int RANK_SIZE = 14;
    bool cards[SUIT_SIZE][RANK_SIZE];

    char s;
    int c, n;

    memset(cards, 0, sizeof(cards));

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> s >> c;
        cards[c2i(s)][c] = true;
    }

    for(int i = 0; i < SUIT_SIZE; i++)
    {
        for(int j = 1; j < RANK_SIZE; j++)
        {
            if(cards[i][j] == false)
                cout << i2c(i)  << " " << j << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3100
# 2019-11-15 14:37:47(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *p = [int(x) for x in sys.stdin.read().split()]

    for i in range(n):
        if p[i] != i + 1:
            if p[p[i]-1] == i + 1:
                p[p[i]-1], p[i] = p[i], i+1
            break

    print('YES' if p == list(range(1, n+1)) else 'NO')


if __name__ == "__main__":
    main()


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

typedef long long ll;
const ll eps = 1e18;
int n;
ll a[100005];
__int128_t ans;
int main(){

    ios::sync_with_stdio(false);
    cin>>n;
    ans=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        ans*=a[i];
        if(ans>eps){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<(ll)ans<<endl;

    return 0;
}


Measured memory_bytes: 4400
n=int(input())
res=[0]*(n+1)
for x in range(1,150):
  for y in range(1,150):
    for z in range(1,150):
      t = x**2+y**2+z**2+x*y+y*z+z*x
      if t > n:
        continue
      res[t]+=1
for i in range(1,n+1):
  print(res[i])


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

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

	for (int i = 1; i *a < a*b; i++) {
		if (a*i % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100000
struct node
{
    int l,r;
}A[MAXN+5];
int n,Q;
bool cmp(node s1,node s2){return s1.r<s2.r;}
int main()
{
    scanf("%d%d",&n,&Q);
    for(int i=1;i<=Q;i++)
    {
        scanf("%d%d",&A[i].l,&A[i].r);
    }
    sort(A+1,A+Q+1,cmp);
    int S=A[1].r,ans=1;
    for(int i=2;i<=Q;i++)
    if(A[i].l>=S)S=A[i].r,ans++;
    printf("%d",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N, K;
    cin >> N >> K;
    long long ans = N;
    set<int> s;
    s.insert(N);
    bool flag = true;
    if(N != K) N = N % K;
    while(flag){
        N = abs(N - K);
        if(s.count(N)) flag = false;
        else{
            s.insert(N);
            ans = min(ans, N);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const ll MOD = 998244353;

int main() {
    int N, K;
    cin >> N >> K;
    vector<pii> rng;

    for (int i = 0; i < K; i++) {
        int l, r;
        cin >> l >> r;
        r++;
        rng.emplace_back(l, r);
    }

    vector<ll> dp(N);
    dp[0] = 1;
    dp[1] = -1;

    for (int i = 0; i < N; i++) {
        if (i > 0) dp[i] = (dp[i] + dp[i - 1]) % MOD;
        for (int j = 0; j < K; j++) {
            int l, r;
            tie(l, r) = rng[j];
            if (i + l < N) dp[i + l] = (dp[i + l] + dp[i]) % MOD;
            if (i + r < N) dp[i + r] = ((dp[i + r] - dp[i]) % MOD + MOD) % MOD;
        }
    }
    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 4460
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  int n, x, y;
  cin >> n >> x >> y;
  x--, y--;
 
  vector<vector<int>> G(n);
  G[x].push_back(y);
  G[y].push_back(x);
 
  rep(i, 0, n - 1) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
 
  vector<int> ans(n - 1, 0);
 
  rep(i, 0, n) {
    queue<int> q;
    vector<int> root(n, 1e9);
    q.push(i);
    root[i] = 0;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      for (auto g : G[t]) {
        if (root[g] != 1e9)
          continue;
        chmin(root[g], root[t] + 1);
        q.push(g);
      }
    }
 
    rep(j, i + 1, n) { ans[root[j] - 1]++; }
  }
 
  rep(i, 0, n - 1) cout << ans[i] << endl;
}

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

using namespace std;
int a[500000],b[500000],n;
long long sums,ans;

int main()
{
    scanf("%d",&n);
    long long sums = 0;int tmp;
    for(int i=0;i<n;++i){
        scanf("%d",&tmp);++a[tmp-1];
    }

    vector<int> vn;
    sort(a,a+n);reverse(a,a+n);
    int j = n-1;
    int rs = 0;
    for(int i=1;i<=n;++i){
        while(j>=0&&a[j]<i){
            rs += a[j--];
        }
        b[i] = rs/i + (j+1);
    }

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


Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    vector<pii> v(N);
    int a, b;
    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        v[i] = pii(a, b);
    }
    sort(v.begin(), v.end());

    priority_queue<int> pq;
    int ans = 0;
    int j = 0;
    for (int i = 1; i <= M; i++) {
        for ( ; j < N && v[j].first <= i; j++) pq.push(v[j].second);
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1660
#include <iostream>
#define llint long long
#define inf (llint)1e18

using namespace std;

int n;
int x[100005];
llint dp[100005];

llint bit[100005];

void init()
{
	for(int i = 1; i <= n; i++){
		bit[i] = i;
	}
}

llint query(int i)
{
	llint ret = -inf;
	while(i > 0){
		ret = max(ret, bit[i]);
		i -= i&(-i);
	}
	return ret;
}

void add(int i, llint val)
{
	while(i <= n){
		bit[i] = max(bit[i], val);
		i += i&(-i);
	}
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i];
	
	for(int i = 1; i <= n; i++){
		dp[x[i]] = query(x[i]) + x[i];
		add(x[i], dp[x[i]]);
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++) ans += i;
	
	llint maxdp = -1;
	for(int i = 1; i <= n; i++){
		maxdp = max(maxdp, dp[i]);
	}
	ans -= maxdp;
	
	cout << ans << endl; 
	return 0;
}

Measured memory_bytes: 5052
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(int argc, char const* argv[])
{
	long double a, b, C;
	cin >> a >> b >> C;
	cout.precision(8);
	cout << fixed << a * b * sin(C*M_PI/180) / 2 << endl;
	cout << fixed << a + b + sqrt(a*a+b*b-2*(a*b * cos(C*M_PI/180))) << endl;
	cout << fixed << b * sin(C * M_PI/180) << endl;
	return 0;
}


Measured memory_bytes: 1340
import heapq

N = int(input())

Tree = [[] for _ in range(N)]
for _ in range(N-1):
  a, b, c = map(int, input().split())
  Tree[a-1].append((c, b-1))
  Tree[b-1].append((c, a-1))

def dijkstra(s):
  hq = [(0, s)]
  heapq.heapify(hq)
  cost = [float('inf')] * N
  cost[s] = 0
  while hq:
    c, v = heapq.heappop(hq)
    if c > cost[v]:
      continue
    for d, u in Tree[v]:
      tmp = d + cost[v]
      if tmp < cost[u]:
        cost[u] = tmp
        heapq.heappush(hq, (tmp, u))
  return cost

Q, K = map(int, input().split())
cost = dijkstra(K-1)

for _ in range(Q):
  x, y = map(lambda x:int(x)-1, input().split())
  print(cost[x]+cost[y])

Measured memory_bytes: 102224
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>, int> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

ll n, m, d, sum = 0;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> d;
    if (d == 0) {
        sum = n;
    } else {
        sum += min(d, n - d); // only go up
        sum += n - max(d, n - d); //only do down
        if (d + 1 <= n - d) {
            sum += 2 * (n - d - (d + 1) + 1);
        }
    }
    double ans = (double) sum / n;
    ans *= (double) (m - 1) / n;
    cout << fixed << setprecision(12);
    cout << ans;
}

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

int n;

bool check(int num){
   int c3=0,c5=0,c7=0;
   if(num<357) return false;
   while(num>0){
      if(num%10==3)c3=1;
      else if(num%10==5)c5=1;
      else if(num%10==7)c7=1;
      num/=10;
      if(c3==1&&c5==1&&c7==1)return true;
   }
   return false;
}


int dfs(long long num,int ans){
   if(num>n) return ans;
   if(check(num))ans++;
   ans=dfs(num*10+3,ans);
   ans=dfs(num*10+5,ans);
   ans=dfs(num*10+7,ans);

   return ans;

}

int main(){
   stack<int> s;
   cin>>n;
   cout<<dfs(0,0)<<endl;
}

Measured memory_bytes: 256
use std::cmp::Ordering;
use std::collections::BinaryHeap;

#[derive(PartialEq, Eq, Debug)]
struct Data {
    i: usize,
    p: usize,
    y: usize,
}

impl Ord for Data {
    fn cmp(&self, other: &Data) -> Ordering {
        if self.p != other.p {
            self.p.cmp(&other.p)
        } else {
            self.y.cmp(&other.y)
        }
    }
}

impl PartialOrd for Data {
    fn partial_cmp(&self, other: &Data) -> Option<Ordering> {
        Some(other.cmp(&self))
    }
}

fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let _: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let mut bheap = BinaryHeap::new();
    for i in 0..m {
        let p: usize = iter.next().unwrap().parse().unwrap();
        let y: usize = iter.next().unwrap().parse().unwrap();
        bheap.push(Data {i: i, p: p, y: y});
    }
    let mut p_x = vec![(0, 0); m];
    let mut pre_p = None;
    let mut cnt = 1;
    while !bheap.is_empty() {
        let Data {i, p, y: _} = bheap.pop().unwrap();
        match pre_p {
            None => pre_p = Some(p),
            Some(x) => {
                if x != p {
                    cnt = 1;
                    pre_p = Some(p);
                }
                else {
                    cnt += 1;
                }
            },
        }
        p_x[i] = (p, cnt);
    }
    for (p, x) in p_x {
        println!("{:>06}{:>06}", p, x);
    }
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}

Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,Y;
    cin >> N >> Y;

    int sen=0,gosen=0,man=0;

    for(int i=0; i<=N; i++){
        man = i;
        for(int j=0; j<=N-i; j++){
            sen = j;
            gosen = N-i-j;
            if(10000*man+5000*gosen+1000*sen == Y){
                    cout << man << " " << gosen << " " << sen << endl;
                    return 0;
            }
        }
    }
    
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
a,b=map(int,raw_input().split())
if a==b:
	print "Draw"
elif a>b:
	if a==13 and b==1:
		print "Bob"
	else:
		print "Alice"
else:
	if b==13 and a==1:
		print "Alice"
	else:
		print "Bob"

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
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;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;


int main() {
  IN(ll ,N);
  AIN(ll, X, N);
  vector<ll> S = X;
  SORT(S);
  REP(i, N){
    if(X.at(i) <= S.at(N/2-1)){
      OUT(S.at(N/2));
    }else{
      OUT(S.at(N/2-1));
    }
  }
}

Measured memory_bytes: 5376
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        sc.close();

        int result = 180*(a-2);

		// 出力
		System.out.println(result);
	}
}


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

int main() {
  string n;
  cin>>n;
  if(n[0]=='S')
  {
    cout<<"Cloudy"<<endl;
  }
  else if(n[0]=='C')
  {
    cout<<"Rainy"<<endl;
  }
  else
  {
    cout<<"Sunny"<<endl;
  }

  //cout<<d<<endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    int x1,x2,x3,y1,y2,y3;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Read();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        double S = (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1);
        S = S > 0 ? S : -S;
        double a,b,c;
        a = Math.Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
        b = Math.Sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
        c = Math.Sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
        double max = a;
        if(max < b){
            max = b;
        }
        if(max < c){
            max = c;
        }
        double r = S/(a+b+c);
        sb.Append((max*r/(2*r+max))+"\n");
    }
    void Read(){
        string[] str = Console.ReadLine().Split(' ');
        x1 = int.Parse(str[0]);
        y1 = int.Parse(str[1]);
        str = Console.ReadLine().Split(' ');
        x2 = int.Parse(str[0]);
        y2 = int.Parse(str[1]);
        str = Console.ReadLine().Split(' ');
        x3 = int.Parse(str[0]);
        y3 = int.Parse(str[1]);
    }    
}

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

int main() {
  int N;
  cin >> N;
  vector<int> number(N);
  for (int i = 0; i < N; i++) {
  	cin >> number.at(i);
  }
  vector<int> count(N);
  for (int i = 0; i < N; i++) {
    while (number.at(i) % 2 == 0) {
      number.at(i) = number.at(i)/2;
      count.at(i)++;
    }
  }
  sort(count.begin(), count.end());
  cout << count.at(0) << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String ans[] = {"Sunny", "Cloudy", "Rainy"};
		for(int i = 0; i < 3; i++) {
			if(S.equals(ans[i])) {
				System.out.println(ans[(i + 1) % 3]);
			}
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <set>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n, Q;
multiset<llint> S;
vector<pair<P, llint> > vec;

int main(void)
{
	cin >> n >> Q;
	llint s, t, x;
	for(int i = 1; i <= n; i++){
		cin >> s >> t >> x;
		vec.push_back(make_pair(make_pair(s-x, 0), x));
		vec.push_back(make_pair(make_pair(t-x, 1), x));
	}
	for(int i = 1; i <= Q; i++){
		cin >> x;
		vec.push_back(make_pair(make_pair(x, 2), 0));
	}
	sort(vec.begin(), vec.end());
	
	for(int i = 0; i < vec.size(); i++){
		//cout << vec[i].first.first << " " << vec[i].first.second << " " << vec[i].second << endl;
		if(vec[i].first.second == 0){
			S.insert(vec[i].second);
		}
		if(vec[i].first.second == 1){
			S.erase(S.lower_bound(vec[i].second));
		}
		if(vec[i].first.second == 2){
			if(S.size() == 0){
				cout << -1 << endl;
				continue;
			}
			cout << *(S.begin()) << endl;
		}
	}
	
	return 0;
}

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

const int maxval=1e3+7,maxn=1e4+7,p=1e9+7;
int prime[maxval],cnt[maxval],v[maxn],n;
bool not_prime[maxval];
set<int> s;
long long ans,lcm=1;

void get_prime()
{
	for(int i=2;i<maxval;++i) {
		if(!not_prime[i]) prime[++prime[0]]=i;
		for(int j=1;j<=prime[0]&&i*prime[j]<maxval;++j) {
			not_prime[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
}

long long poww(int x,int y)
{
	long long ans=1,tmp=x;
	while(y) {
		if(y&1) ans=ans*tmp%p;
		tmp=tmp*tmp%p;
		y>>=1;
	}
	return ans;
}

int main()
{
	get_prime();
	scanf("%d",&n);
	int t=0;
	for(int i=1;i<=n;++i) {
		scanf("%d",&v[i]);
		int j=1,c=0,a=v[i];
		while(a!=1&&j<=prime[0]) {
			while(a%prime[j]==0) c++,a/=prime[j];
			cnt[j]=max(cnt[j],c);
			j++;c=0;t=max(j,t);
		}
		if(a!=1) s.insert(a);
	}
	for(int i=1;i<=t;++i) {
		if(cnt[i]) lcm=lcm*poww(prime[i],cnt[i])%p;
	}
	if(!s.empty()) {
		set<int>::iterator it=s.begin();
		while(it!=s.end()) lcm=lcm*(*it)%p,it++;
	}
	lcm%=p;
	for(int i=1;i<=n;++i) {
		ans+=lcm*poww(v[i],p-2)%p;
		ans%=p;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 768