akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

const LL mod = 1000000007;
LL N,a[100010],C[100010],C2[100010];
vector<LL> p[100010];

LL inv(LL nr){
    LL p=mod-2,res=1;
    while (p){
        if (p&1) res=(res*nr)%mod;
        nr=(nr*nr)%mod;
        p>>=1;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    N++;

    int i;
    for (i=1; i<=N; i++){
        cin >> a[i];
        p[a[i]].push_back(i);
    }



    LL tot=0;
    for (i=1; i<=N; i++)
        if (p[i].size()==2)
            tot=(p[i][0]-1+N-p[i][1]);

    C[0]=C2[0]=1;
    for (i=1; i<=N; i++){
        C[i]=(C[i-1]*(N-i+1))%mod;
        C[i]=(C[i]*inv(i))%mod;

        C2[i]=(C2[i-1]*(tot-i+1))%mod;
        C2[i]=(C2[i]*inv(i))%mod;
    }

    for (i=1; i<=N; i++)
        cout << (C[i]-C2[i-1]+mod)%mod << "\n";
    return 0;
}


Measured memory_bytes: 9088
class UnionFind:
    def __init__(self, size):
        # -nが木のroot
        # 親ノードの位置を格納
        self.table = [-1 for i in range(size)]

    def _find(self, x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x

    def find(self, x):
        if self.table[x] < 0:
            return x
        self.table[x] = self.find(self.table[x])
        return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] >= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def get_ntree(self):
        res = 0
        for c in self.table:
            if c < 0:
                res += 1
        return res

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_nclass(self):
        done = []
        for x in range(len(self.table)):
            if x in done:
                continue
            while self.table[x] >= 0:
                done.append(x)
                x = self.table[x]

    def get_nodenum(self):
        res = []
        for t in self.table:
            if t < 0:
                res.append(-t)

        return res


def ij_to_n(i, j, W):
    return i*W+j


def n_to_ij(n, W):
    return (n//W, n % W)


def acinput():
    return list(map(int, input().split(" ")))


if __name__ == '__main__':
    a, b = acinput()

    uf = UnionFind(a)
    for i in range(b):
        s, t = acinput()
        uf.union(s-1, t-1)

    print(-min(uf.table))


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

#define MAX 200000
#define NIL -1

//左子右兄弟表現を使っている

struct Node {
    int parent;
    int left;
    int right;
};

Node T[MAX];
//D[]は深さを数列として落とし込んだもの
int n, D[MAX];

/*int getDepth(int u) {
    int d = 0;

    while(T[u].parent!=NIL) {
        u = T[u].parent;
        d++;
    }

    return d;
}*/

void setDepth(int u, int p) {
    D[u] = p;
    if(T[u].right!=NIL) {
        setDepth(T[u].right, p);
    }
    if(T[u].left!=NIL) {
        setDepth(T[u].left,  p+1);
    }
}

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].parent==NIL) {
        cout << "root, ";
    }
    else if(T[u].left==NIL) {
        cout << "leaf, ";
    }
    else {
        cout << "internal node, ";
    }

    cout << "[";

    for(i=0, c=T[u].left; c!=NIL; i++, c=T[c].right) {
        if(i) {
            cout << ", ";
        }
        cout << c;
    }
    cout << "]" << endl;
}

int main() {
    int d, v, c, r, l;
    cin >> n;
    for(int i=0; i<n; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    for(int i=0; i<n; i++) {
        //id（節点の番号）をvに、次数をdに入れる
        cin >> v >> d;
        for(int j=0; j<d; j++) {
            cin >> c;
            if(j==0) {
                T[v].left = c;
            }
            else {
                T[l].right = c;
            }
            l = c;
            T[c].parent = v;
        }
    }
    for(int i=0; i<n; i++) {
        if(T[i].parent==NIL) {
            r = i;
        }
    }

    setDepth(r, 0);

    for(int i=0; i<n; i++) {
        print(i);
    }

    return 0;
}


Measured memory_bytes: 7664
def examA():
    N = I(); A = LI()
    sumnale = sum(A)/N
    cur = 10**9; curL = 0
    for i in range(N):
        if cur>abs(A[i]-sumnale):
            cur = abs(A[i]-sumnale)
            curL = i
    ans = curL
    print(ans)
    return


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


Measured memory_bytes: 38384
/*
 * 1 以上 N 以下の整数のうち、10 進法での各桁の和が A 以上 B 以下であるものの総和を求めてください。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());

            //解の和sum
            int sum = 0;
            // 各位の和のtemp、sumone
            int sumone = 0;

            for(int i=1; i<=n; i++){
            	sumone = i/10000 + (i/1000)%10 + (i/100)%10 + (i/10)%10 + i%10;
            	
            	if(a <= sumone &&  sumone <= b){
            		sum += i;
           		}
            }

            //出力
            System.out.println(sum);
            sc.close();
        }
    }


Measured memory_bytes: 21844
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#include<bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

char ara[7][7],temp[7][7];

void solve()
{
	int n,m,b;
	cin>>n>>m>>b;
	
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>ara[i][j];
	
	int ans=0;
	
	for(int i=0;i<1<<(n+m);i++)
	{
		for(int j=0;j<n;j++) 
		{
			for(int k=0;k<m;k++) temp[j][k]=ara[j][k];
		}
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				fill(temp[j],temp[j]+m,'R');
			}
		}
		for(int j=n,k=0;k<m;j++,k++)
		{
			if(i&(1<<j))
			{
				for(int p=0;p<n;p++) temp[p][k]='R';
			}
		}
		
		int cnt=0;
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<m;k++)
			{
				if(temp[j][k]=='#') cnt++;
			}
		}
		
		if(cnt==b) ans++;
	}
	
	cout<<ans;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 3656
let kyu x =
  if 400 <= x && x <= 599 then 8
  else if 600 <= x && x <= 799 then 7
  else if 800 <= x && x <= 999 then 6
  else if 1000 <= x && x <= 1199 then 5
  else if 1200 <= x && x <= 1399 then 4
  else if 1400 <= x && x <= 1599 then 3
  else if 1600 <= x && x <= 1799 then 2
  else 1

let () = Printf.printf "%d\n" (kyu (read_int ()))

Measured memory_bytes: 3684
h, w, num = map(int, input().split())
a = [input() for _ in range(h)]
ans = 0

for j in range(2**h):
    b1 = ['-']*h
    for k in range(h):
        if ((j>>k)&1):
            b1[h-1-k] = '+'
    for i in range(2**w):
        b2 = ['-']*w
        for k in range(w):
            if ((i>>k)&1):
                b2[w-1-k] = '+'
        val = 0
        for n in range(h):
            for m in range(w):
                if b1[n] == '-' and b2[m] == '-' and a[n][m] == '#':
                    val += 1
        if val == num:
            ans += 1
print(ans)                        

        


Measured memory_bytes: 9228
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

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

	double sum = 0;
	for (int i = 0;i < k;i++) {
		sum += p[i];
	}

	double max = sum;
	
	for (int i = 0;i < n - k;i++) {
		sum += p[i + k];
		sum -= p[i];
		if (max < sum) max = sum;
	}
	double ans = (max + (double)k) / 2;
	printf("%.10lf", ans);
	return 0;
}

//CCCCCCCCCCCC
//int main() {
//	int n;
//	cin >> n;
//	map<int, int> a;
//
//	for (int i = 0;i < n;i++) {
//		int j;
//		cin >> j;
//		a[j]++;
//		if (a[j] == 2) {
//			cout << "NO" << endl;
//			return 0;
//		}
//	}
//
//	cout << "YES" << endl;
//	return 0;
//}

//BBBBBBBBBBBB
//int main(){
//	string s;
//	cin >> s;
//
//	for (int i = 0;i < s.length();i++) {
//		printf("x");
//	}
//
//	return 0;
//}

//AAAAAAAAAAAA
//int main() {
//	string s, t, u;
//	int a, b;
//	cin >> s >> t >> a >> b >> u;
//
//	if (s == u)a--;
//	else b--;
//
//	cout << a << " " << b << endl;
//	return 0;
//}

Measured memory_bytes: 4024
s=int(input())
A=[s]
while s!=1:
    if s%2==0:
        s=s//2
        A.append(s)
    else:
        s=(3*s)+1
        A.append(s)
AA=A+[4,2,1]
if AA[0]==1 or AA[0]==2:
    print(4)
else:
    for m in range(len(AA)):
        for n in range(len(AA)):
            if AA[m]==AA[n] and m>n:
                M=m-1
                break
    print(M)

Measured memory_bytes: 9192
N, M = map(int, input().split())

A = []
if N == 1:
    A = [0]
elif N == 2:
    A = [1, 0]
elif N == 3:
    A = [1, 0, 0]

f = [0, 0, 0]
ng = 0

for i in range(M):
    s, c = map(int, input().split())
    if N >= 2 and s == 1 and c == 0:
        ng = 1
        continue
    if f[s - 1] == 0:
        A[s - 1] = c
        f[s - 1] = 1
    else:
        if A[s - 1] == c:
            continue
        else:
            ng = 1

if ng == 1:
    print(-1)
else:
    ans = ''
    for i in range(N):
        ans += str(A[i])
    print(ans)

Measured memory_bytes: 38336
N = int(input())
city = []
point = []
for i in range(N):
    S,P = input().split()
    P = int(P)
    city += [S]
    point += [P]

citys = sorted(city)
i = 0
while i < N:
    how = city.count(citys[i])
    if how == 1:
        print(city.index(citys[i])+1)
        i += 1
    else:
        indexes = [j for j, x in enumerate(city) if x == citys[i]]
        points = sorted([point[j] for j in indexes])[::-1]
        for k in points:
            print(point.index(k)+1)
        i += len(indexes)


Measured memory_bytes: 3064
#include <stdio.h>
#define MAX 100000
  
int A[MAX];
  
int partition(int p,int r){
    int x=A[r];
    int i=p-1;
    int j,store;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i+=1;
            store=A[i];
            A[i]=A[j];
            A[j]=store;
        }
    }
    store=A[i+1];
    A[i+1]=A[r];
    A[r]=store;
    return i+1;
}
  
int main(){
    int n,i;
    int prt;
    scanf("%d",&n);
      
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    prt=partition(0,n-1);
      
    for(i=0;i<n;i++){
        if(i==prt) printf("[%d]",A[i]);
        else printf("%d",A[i]);
        if(i>=0&&i<n-1) printf(" ");
    }
    printf("\n");
      
    return 0;
}

Measured memory_bytes: 988
#include <cmath>
#include <iostream>
#include <set>
using namespace std;

int main(void) {
  long long N, D;
  int count = 0;
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    long long X, Y;
    cin >> X >> Y;
    if (X * X + Y * Y <= D * D) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int count;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {
			count = 0;
			int n = Integer.parseInt(line.split(" ")[0]);
			int s = Integer.parseInt(line.split(" ")[1]);
			solve(0, n, s);
			System.out.println(count);
		}
	}

	// p: 算入する数字
	// n: 算入する数字の数
	// s: 目標の合計値
	static void solve(int p, int n, int s) {
		if (p > 9 || n == 0 || p > s) {
			return;
		}
		if (n == 1 && p == s) {
			count++;
		}
		solve(p + 1, n - 1, s - p);
		solve(p + 1, n, s);
	}
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;

const int DEBUG = 0;

int main(){
	//ios_base::sync_with_stdio(false);
	int N, ans=0;
	cin >> N;
	vector<int> b;
	b.resize(N);

	rep(i, N){
		cin >> b[i];
	}

	vector<int> a;
	for(int i = N -1; i >= 0; --i){
		bool flag = true;
		vector<int> c;
		if(DEBUG){
			cout << "DEBUG" << endl;
			rep(i, b.size()){
				cout << b[i] << endl;
			}
		}
		for(int j = i; j >= 0; --j){
			if(flag && b[j] == (j+1)){
				flag = false;
				a.push_back(j+1);
				if(DEBUG){
					cout << "DEBUG poped" << b[j] << endl;
				}
				
				continue;
			}
			c.push_back(b[j]);
		}
		if(flag){
			cout << "-1" << endl;
			return 0;
		}
		reverse(all(c));
		b = c;
	}
	reverse(a.begin(), a.end());
	rep(i, N) cout << a[i] << endl;

	return 0;
}


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

MOD = 10 ** 9 + 7

n = int(input())

graph = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u - 1].append((v - 1, w))
    graph[v - 1].append((u - 1, w))

dist = [-1] * n
dist[0] = 0
que = [0]
while len(que) != 0:
    i = que.pop()
    for j, w in graph[i]:
        if dist[j] == -1:
            dist[j] = dist[i] + w
            que.append(j)

for d in dist:
    print(d % 2)



Measured memory_bytes: 42796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vii A(N);
  vi B(N);
  rep(i,1,N+M){
    int X,Y; cin>>X>>Y;
    A[X-1].pb(Y-1);
    B[Y-1]++;
  }
  stack<int> Q;
  vi C;
  rep(i,0,N){
    if(B[i]==0) Q.push(i);
  }
  while(Q.size()>0){
    int X=Q.top();
    Q.pop();
    C.pb(X);
    rep(i,0,A[X].size()){
      int Y=A[X][i];
      B[Y]--;
      if(B[Y]==0) Q.push(Y);
    }
  }
  vi D(N);
  rep(i,0,N){
    int X=C[i];
    rep(j,0,A[X].size()){
      int Y=A[X][j];
      D[Y]=C[i]+1;
    }
  }
  rep(i,0,N) cout<<D[i]<<endl;
  }



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

struct point {
  int x, y;
};

struct data {
  int num, sum, l, r;
};

int w, h;
int d[4] = {0, 1, 0, -1};
vector<string> p;
vector<vector<int>> num, edges;
vector<data> piece;
vector<bool> used;

bool solve();
int makegraph(point nowp);
bool isvalid(point now);
bool check(int now);

int main() {
  while(1) {
    cin >> w >> h;
    if(w + h == 0) break;
    p.resize(h);
    for(int i = 0; i < h; ++i) cin >> p[i];
    if(solve())
      cout << "STABLE" << endl;
    else
      cout << "UNSTABLE" << endl;
    piece.erase(piece.begin(), piece.end());
    edges.erase(edges.begin(), edges.end());
  }
  return 0;
}

bool solve() {
  bool ans = 1;
  num.assign(h, vector<int>(w, -1));
  for(int i = h - 1; i >= 0; --i)
    for(int j = 0; j < w; ++j)
      if(p[i][j] != '.' && num[i][j] == -1)
        makegraph({i, j});
  for(int i = 0; i < piece.size(); ++i) ans &= check(i);
  return ans;
}

int makegraph(point nowp) {
  int nowid = piece.size();
  char nowc = p[nowp.x][nowp.y];
  // make data
  piece.push_back({0, 0, 10000, -1});
  edges.push_back(vector<int>(0));

  stack<point> st;
  num[nowp.x][nowp.y] = nowid;

  st.push(nowp);

  while(st.size()) {
    point now = st.top();
    st.pop();
    piece[nowid].sum += now.y;
    ++piece[nowid].num;
    if(now.x == h - 1 || (isvalid({now.x + 1, now.y}) &&
                          p[now.x + 1][now.y] != nowc)) {
      piece[nowid].l = min(piece[nowid].l, now.y);
      piece[nowid].r = max(piece[nowid].r, now.y);
    }
    if(isvalid({now.x - 1, now.y}) &&
       p[now.x - 1][now.y] != nowc) {
      if(num[now.x - 1][now.y] == -1)
        edges[nowid].push_back(
            makegraph({now.x - 1, now.y}));
      else
        edges[nowid].push_back(num[now.x - 1][now.y]);
    }

    for(int i = 0; i < 4; ++i) {
      point nextp = now;
      nextp.x += d[i];
      nextp.y += d[1 ^ i];
      if(!isvalid(nextp)) continue;
      if(p[nextp.x][nextp.y] == nowc &&
         num[nextp.x][nextp.y] == -1) {
        num[nextp.x][nextp.y] = nowid;
        st.push(nextp);
      }
    }
  }
  return nowid;
}

bool check(int now) {
  used.assign(piece.size(), 0);
  data sumd = piece[now];
  stack<int> st;
  st.push(now);
  used[now] = 1;
  while(!st.empty()) {
    int nowp = st.top();
    st.pop();
    for(int i = 0; i < edges[nowp].size(); ++i)
      if(!used[edges[nowp][i]]) {
        sumd.sum += piece[edges[nowp][i]].sum;
        sumd.num += piece[edges[nowp][i]].num;
        used[edges[nowp][i]] = 1;
        st.push(edges[nowp][i]);
      }
  }
  return (double)sumd.l - 0.5 <
             (double)sumd.sum / sumd.num &&
         (double)sumd.sum / sumd.num < (double)sumd.r + 0.5;
}

bool isvalid(point now) {
  return now.x >= 0 && now.x < h && now.y >= 0 &&
         now.y < w && p[now.x][now.y] != '.';
}


Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>

/*
ax + by = c
dx + ey = f

x = (c-by)/a
d(c-by)/a + ey = f
dc/a - dby/a + ey = f
ey - dby/a = f - dc/a
y(e-db/a) = f - dc/a
y = (f-dc/a)/(e-db/a)

*/
int main()
{
    while(true){
        double a, b, c, d, e, f;
        std::cin >> a >> b >> c >> d >> e >> f;
        if(std::cin.eof()) break;
        double y = (f-d*c/a)/(e-d*b/a);
        double x = (c-b*y)/a;
        std::cout << std::fixed << std::setprecision(3);
        std::cout << x << " " << y << std::endl;
    }
    return 0;
}

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

int main()
{
    int n, m, x, y, i, j, dis, res;
    int gems[MAX][MAX];
    char dir;
    while (cin >> n, n) {
        for (i = 0; i < MAX; ++i)
            for (j = 0; j < MAX; ++j)
                gems[i][j] = 0;
        for (i = 0; i < n; ++i) {
            cin >> x >> y;
            gems[x][y] = 1;
        }
        x = y = 10;
        res = gems[x][y];
        cin >> m;
        for (i = 0; i < m; ++i) {
            cin >> dir >> dis;
            if (dir == 'N')
                for (j = 0; j < dis; ++j) {
                    res += gems[x][++y];
                    gems[x][y] = 0;
                }
            if (dir == 'E')
                for (j = 0; j < dis; ++j) {
                    res += gems[++x][y];
                    gems[x][y] = 0;
                }
            if (dir == 'S')
                for (j = 0; j < dis; ++j) {
                    res += gems[x][--y];
                    gems[x][y] = 0;
                }
            if (dir == 'W')
                for (j = 0; j < dis; ++j) {
                    res += gems[--x][y];
                    gems[x][y] = 0;
                }
        }
        if (res == n)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> height(N);
    rep(i,N){
        cin >> height[i];
    }
    int max_count = 0;
    int count = 0;
    rep(i,N - 1){
        if (height[i] >= height[i + 1]){
            count++;
            max_count = max(count,max_count);
        }
        else{
            count = 0;
        }
    }
    cout << max_count << endl;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

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

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

	string digits = "";
	ll i = 0, base = 1;

	if (N == 0) cout << 0 << endl;
	else {
		while (N)
		{
			if (N % (base * 2) == 0) digits += '0';
			else
			{
				digits += '1';
				N -= base;
			}

			i++;
			base *= -2;
		}
	}
	reverse(digits.begin(), digits.end());
	cout << digits << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
ll h1[300005];
ll h2[300005];
ll h3[300005];
ll p1[300005];
ll p2[300005];
ll p3[300005];
ll p = 998244353ll;
ll b1 = 97ll;
ll b2 = 109ll;
ll b3 = 113ll;
 
pair<ll, pair<ll, ll>> get_hash(ll l, ll r);
 
int main() {
    string s;

    cin >> s;
    
    p1[0] = 1;
    p2[0] = 1;
    p3[0] = 1;
    for (int i = 1; i <= s.size(); i++) {
        p1[i] = (p1[i - 1] * b1) % p;
        p2[i] = (p2[i - 1] * b2) % p;
        p3[i] = (p3[i - 1] * b3) % p;
    }
 
    h1[0] = s[0];
    h2[0] = s[0];
    h3[0] = s[0];
    for (int i = 1; i < s.size(); i++) {
        h1[i] = (h1[i - 1] * b1 + s[i]) % p;
        h2[i] = (h2[i - 1] * b2 + s[i]) % p;
        h3[i] = (h3[i - 1] * b3 + s[i]) % p;
    }

    ll prev = 1;
    pair<ll, pair<ll, ll>> prev_h = get_hash(0, 0);
    ll ans = 1;
    for (int i = 1; i < s.size(); i++) {
        if (prev_h != get_hash(prev, i)) {
            ans++;
            prev_h = get_hash(prev, i);
            prev = i + 1;
        }
    }
  
    cout << ans << endl;
     
    return 0;
}
 
pair<ll, pair<ll, ll>> get_hash(ll l, ll r) {
    l--;
    ll f, sf, ss;
     
    if (l < 0) {
        f = h1[r];
        sf = h2[r];
        ss = h3[r];
    }
    else {
        f = ((h1[r] - h1[l] * p1[r - l])%p + p) % p;
        sf = ((h2[r] - h2[l] * p2[r - l])%p + p) % p;
        ss = ((h3[r] - h3[l] * p3[r - l])%p + p) % p;
    }
 
    return pair<ll, pair<ll, ll>>(f, pair<ll, ll>(sf, ss));
}


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

using namespace std;
int dp[100000],n,arr[100000];
int bt(int i)
{
    if(dp[i]!=-1)
        return dp[i];
    if(i==n)
        return 99999999;
    if(i==n-1)
        return 0;
    int &ret=dp[i];
    ret=min(bt(i+1)+abs(arr[i]-arr[i+1]),bt(i+2)+abs(arr[i]-arr[i+2]));
    return ret;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    cout<<bt(0);
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

vector<ll> sieve_of_eratosthenes(ll n) {
  vector<ll> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;

  vector<ll> primes2017(0);
  for(int i = 2; i < n; ++i){
    if(primes[i]!=0&&primes[(i+1)/2]!=0){
      primes2017.pb(i);
    }
  }
  return primes2017;
}

int main(){
    ll q;cin>>q;
    vector<ll> l(q),r(q);
    vector<ll> primes;
    ll max_r=0;
    rep(i,q){
      cin>>l[i]>>r[i];
      max_r=max(max_r,r[i]);
    }

    primes = sieve_of_eratosthenes(2*max_r);

    ll tempu=primes.size()-1;
    ll templ=0;
    ll target;
    ll l_index,u_index;
    rep(i,q){
      tempu=primes.size()-1;
      templ=0;
      target=r[i];
      while(tempu-templ>1){
        if(target>=primes[int((tempu-templ)/2)+templ]){
          templ=int((tempu-templ)/2)+templ;
        }else{
          tempu=int((tempu-templ)/2)+templ;
        }
      }
      u_index=templ;

      tempu=primes.size()-1;
      templ=0;
      target=l[i];
      while(tempu-templ>1){
        if(target>primes[int((tempu-templ)/2)+templ]){
          templ=int((tempu-templ)/2)+templ;
        }else{
          tempu=int((tempu-templ)/2)+templ;
        }
      }
      l_index=tempu;
      if(l_index==1&&l[i]<=primes[0]){
        l_index=0;
      }
      cout<<u_index - l_index + 1 << endl;

    }


    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<string>
#include<stdlib.h>
#include<ctype.h>
#include<queue>
#include<bitset>
#include<deque>
#include<set>
#include<time.h>
#include<math.h>
#include<sstream>
#include<functional>
#include<stack>
#include<map>
#include<vector>
using namespace std;

#define LL long long
#define MAXN 200000
int f[21];
double dp[29][400009];

double deal(int p,int val){
	double rs=1.0;
	for(int i=1;(i*val) <= (MAXN);i++){
		rs = min(rs,dp[p+1][i*val]);
	}
	return rs;	
}
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF){
		for(int i=0;i<n;i++)
			cin >> f[i];
		sort(f,f+n);
		for(int i=0;i<=n;i++)
			for(int j=1;j<=MAXN;j++)
				dp[i][j]=1.0;
		for(int i=1;i<=MAXN;i++)
			dp[n-1][i]=1.0*abs(f[n-1]-i)/f[n-1];
		for(int i=n-2;i>=0;i--){
			for(int j=1;j<=MAXN;j++){
				dp[i][j]=max(deal(i,j), 1.0*abs(f[i]-j)/f[i]);
			}
		}
		double ans = 1.0;
		for(int i=1;i<=MAXN;i++){
			ans = min(dp[0][i],ans);
		}
		printf("%.19lf\n",ans);
	}
	
	
	return 0;
}

Measured memory_bytes: 32000
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    ll n;
    while(cin>>n){
        vector<bool> ip;
        if(ip.size()<n+1){
            ip.resize(n+1,true);
        }
        ip[0]=false;
        ip[1]=false;
        for(int i=2;i<=(n+1)/2;i++){
            for(int j=2;i*j<n+1;j++){
                ip[i*j]=false;
            }
        }
        ll ans=0;
        for(int i=0;i<n+1;i++){
            if(ip[i])ans++;
        }
        
        
        cout<<ans<<endl;
        
        
        
    }





return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  ll n;
  cin>>n;
  ll before=n;
  ll total=0;
  while(n>0){
    total+=(n%10);
    n/=10;
  }
  if(before%total==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3620
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let s: String = input.next();
    let mut x: usize = 0xff;
    for c in 0..26 {
        let t = s.split(('a' as u8 + c) as char)
            .map(|x| x.chars().count())
            .max()
            .unwrap();
        if x > t {
            x = t;
        }
    }
    println!("{}", x);
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,k;
    cin >> a >> b >> k;
    for(int i = a;i <= b;i++) {
        if((0 <= i - a && i - a < k) || (0 <= b - i && b - i < k)) {
            cout << i << endl;
        }
    }
}


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

using namespace std;

int main(){
    int a,b,k; cin >> a >> b >> k;
    int gcd = __gcd(a,b);
    for(int i = gcd, j = 1;i > 0; i--){
        if(gcd % i == 0){
            if(j == k){
                cout << i << "\n";
                break;
            } 
            j++;
        } 
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

#define REP(i,x) for (int i=0; i<n; i++)
 
using namespace std;


int main(){
    int A, B, C;;
    cin >> A >> B >> C;
    if(A+B<C){
        cout << A+2*B+1;
    }else{
        cout << B+C;
    }
	
	
}

Measured memory_bytes: 256
def func():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))

    l = 0
    r = K - 1

    mn = 10e+8
    while r < N:
        ltor = abs(x[l]) + abs(x[r] - x[l])
        rtol = abs(x[r]) + abs(x[l] - x[r])

        mn = min(mn, min(ltor, rtol))
        l += 1
        r += 1

    print(mn)


if __name__ == '__main__':
    func()


Measured memory_bytes: 62576
MOD = 10 ** 9 + 7
N, M = map(int, input().split())
table = [0] * (N + 1)
table[0] = 1
banned = [0] * (N + 1)
for _ in range(M):
    banned[int(input())] = 1
for i in range(N + 1):
    now = table[i]
    if i + 1 < N + 1 and not banned[i + 1]:
        table[i + 1] = (table[i + 1] + now) % MOD
    if i + 2 < N + 1 and not banned[i + 2]:
        table[i + 2] = (table[i + 2] + now) % MOD
print(table[N])

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static long[] ans = new long[]{-1,-1,-1};
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int K = nextInt()-1;
		String S = nextString();
		String ans = S.substring(0,K)+String.valueOf(S.charAt(K)).toLowerCase()+S.substring(K+1,S.length());
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
use proconio::input;

fn main() {
    input! {
        n: i32,
        k: i32,
    }
    let mut res: i32 = 0;

    let mut sunuke: Vec::<i32> = Vec::new();

    for _i in 0..k {
        input! {
            mut i: i32,
            mut s: [i32; i],
        }
        sunuke.append(&mut s);
    }
    sunuke.sort();
    sunuke.dedup();

    for _i in 1..n + 1 {
        if !sunuke.contains(&(_i)) {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    priority_queue<int> small, big;
    int q, x = 0, ssum = 0, bsum = 0, bb = 0;
    cin >> q;

    while (q--)
    {
        int f, a, b;
        cin >> f;

        if (f == 1)
        {
            cin >> a >> b;

            bb += b;
            if (small.size() == 0)
                small.push(a), ssum += a;
            else if (small.top() < a)
                big.push(-a), bsum += a;
            else
                small.push(a), ssum += a;
            if (small.size() > big.size())
                bsum += small.top(), ssum -= small.top(), big.push(-small.top()), small.pop();
            if (big.size() > small.size())
                bsum += big.top(), ssum -= big.top(), small.push(-big.top()), big.pop();
            x = small.top();
        }
        else
            cerr << x << '\n', cout << x << ' ' << (x * (int)small.size() - ssum) + (bsum - x * (int)big.size()) + bb << '\n';
    }

    return 0;
}


Measured memory_bytes: 3828
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  string str;
  std::cin >> str;

  // std::cout << str << '\n';
  int n = str.size();

  int i = 0;
  int st = 0;
  int s = 0;

  while (i < n) {
      while (str[i] == 'S') {
        //   std::cout << "S: " << i << std::endl;
          s ++;
          i ++;
      }

      while (str[i] == 'T' && s > 0) {
        //   std::cout << "T: " << i << std::endl;
          s --;
          st ++;
          i ++;
      }

      if (str[i] == 'T') {
          i++;
          continue;
      }

  }

  std::cout << n - st * 2 << std::endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
	char a;
	cin>>a;
	if(a=='a') cout<<'b';
	if(a=='b') cout<<'c';
	if(a=='c') cout<<'d';
	if(a=='d') cout<<'e';
	if(a=='e') cout<<'f';
	if(a=='f') cout<<'g';
	if(a=='g') cout<<'h';
	if(a=='h') cout<<'i';
	if(a=='i') cout<<'j';
	if(a=='j') cout<<'k';
	if(a=='k') cout<<'l';
	if(a=='l') cout<<'m';
	if(a=='m') cout<<'n';
	if(a=='n') cout<<'o';
	if(a=='o') cout<<'p';
	if(a=='p') cout<<'q';
	if(a=='q') cout<<'r';
	if(a=='r') cout<<'s';
	if(a=='s') cout<<'t';
	if(a=='t') cout<<'u';
	if(a=='u') cout<<'v';
	if(a=='v') cout<<'w';
	if(a=='w') cout<<'x';
	if(a=='x') cout<<'y';
	if(a=='y') cout<<'z';
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    vector<pair<int,int> > tree[n+1];
    vector<int> visited(n+1,0);
    vector<int> edges(n-1, 0);
    int t1, t2;
    for(int i=0; i<n-1; i++){
        cin >> t1 >> t2;
        tree[t1].pb(make_pair(t2, i));
        tree[t2].pb(make_pair(t1, i));
    }

    int root=1;
    queue<int> bstk;
    bstk.push(root);
    int cur=1;
    int cur1=0;

    int c=1;
    while(!bstk.empty()){
        int top = bstk.front();
        visited[top]=1;
        set<int> colors;
        c=1;
        // cout << top << endl;
        bstk.pop();
        cur--;

        for(int i=0; i<tree[top].size(); i++){
            if(edges[tree[top][i].s] != 0)
                colors.insert(edges[tree[top][i].s]);
        }
        for(int i=0; i<tree[top].size(); i++){
            if(!visited[tree[top][i].f]){
                bstk.push(tree[top][i].f);
                cur1++;

                // Coloring the edges

                while(colors.find(c)!=colors.end())
                    c++;
                edges[tree[top][i].s]=c;
                colors.insert(c);
                c++;    
            }
        }

        if(cur==0){
            cur=cur1;
            cur1=0;
            c=1;
        }
    }
    int ans=0;
    for(int i=0; i<n-1; i++)
        ans=max(ans, edges[i]);
    cout << ans << endl;
    for(int i=0; i<n-1; i++)
        cout << edges[i] << endl;
    // cout << endl;
 
 
    return 0;
}

Measured memory_bytes: 7424
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e18 + 7;

ll N, P, wa; bool flag = false;


int main(void) {
	cin >> N;
	FOR(i, 0, N) {
		ll a; cin >> a;
		if (a % 2 != 0) {
			ct("first");
			flag = true;
			break;
		}
	}
	if (!flag)ct("second");
	
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    int64_t b = -1, bi = -1, s = 0;
    for (auto i : irange(0L, n)) {
        int64_t a;
        cin >> a;
        if (abs(a) > b) {
            b = abs(a);
            bi = i;
            s = a == 0 ? 0 : (a / abs(a));
        }
    }

    cout << 2 * n - 1 << endl;
    for (auto i : irange(0L, n)) {
        cout << bi + 1 << " " << i + 1 << "\n";
    }

    if (s > 0) {
        for (auto i : irange(0L, n - 1)) {
            cout << i + 1 << " " << i + 2 << "\n";
        }
    } else {
        for (auto i : irange(0L, n - 1) | reversed) {
            cout << i + 2 << " " << i + 1 << "\n";
        }
    }
}

Measured memory_bytes: 256
# bable sort
def bubbleSort(o_nums, n):
    nums=o_nums[:]
    for i in range(len(nums)-1):
        for j in range(len(nums)-1,i,-1):
            if nums[j][1]<nums[j-1][1]:
                nums[j],nums[j-1]=nums[j-1],nums[j]  
    return nums

# selection sort
def selectionSort(o_nums,n):
    nums=o_nums[:]
    for i in range(n):
        minj=i
        for j in range(i,n):
            if nums[j][1]<nums[minj][1]:
                minj=j
        if nums[i][1]!=nums[minj][1]:
            nums[i],nums[minj]=nums[minj],nums[i]
    return nums

n=int(input())
cards=list(input().split())

b=bubbleSort(cards, n)
s=selectionSort(cards,n)
print(*b)
print("Stable")
print(*s)
if bubbleSort(cards, n) == selectionSort(cards, n):
    print("Stable")
else:
    print("Not stable")

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}
int q[51][4];
int ma=0;
int n,m,Q;
void calc(vector<int>&v){
     int sum=0;
     for(int i=0;i<Q;i++){
     	if(q[i][2]==v[q[i][1]]-v[q[i][0]])sum+=q[i][3];
     }
     maxs(ma,sum);
}
void recur(int i,int j,vector<int>v){
	if(i>n){
		calc(v);return;
	}
	else{
		for(int k=j;k<=m;k++){
			vector<int>temp=v;
			temp[i]=k;
			recur(i+1,k,temp);
		}
	}
}
int solve(){
 cin>>n>>m>>Q;
 rep3(Q)cin>>q[i][0]>>q[i][1]>>q[i][2]>>q[i][3];
 vector<int>temp(n+1,0);
 recur(1,1,temp);
 cout<<ma<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 3616
using System;


namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] value = str.Split(' ');
            int x = int.Parse(value[0]);
            int a = int.Parse(value[1]);
            if (x < a)
                Console.WriteLine(0);
            else Console.WriteLine(10);
            Console.ReadLine();
        }
        
      
    }

}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	cout << n/(a+b)*a+min(n%(a+b),a);
	// your code goes here
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#define N 10000
int A[2000001],C[N],B[2000001];
int main()
{
  int i,n;

  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }

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

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 18360
n = int(input())
RED, BLUE = [], []
for _ in range(n):
    RED.append(tuple(map(int, input().split())))
for _ in range(n):
    BLUE.append(tuple(map(int, input().split())))

RED = sorted(RED, key=lambda x: x[0], reverse=True)

count = 0
for r in RED:
    for b in sorted(BLUE, key=lambda x: x[1]):
        if r[0] <= b[0] and r[1] <= b[1]:
            BLUE.remove(b)
            count += 1
            break
    
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll h, w;
    cin >> h >> w;

    vvl a(h, vl(w));
    vvl b(h, vl(w));
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
            b[i][j] = a[i][j];
        }
    }

    vl x(h*w), y(h*w);  // うなぎのi番目の座標が(x[i], y[i])

    rep(i, h) {
        rep(j, w) {
            x[i*w + j] = i;
        }
    }

    rep(i, h*w) {
        ll m = i%(2*w);
        if(m < w) {
            y[i] = m;
        }
        else {
            y[i] = (2*w - 1) - m;
        }
    }   
    
    ll N = 0;   
    rep(i, h*w) {
        if(b[x[i]][y[i]]%2 == 1 && i < h*w-1) {
            N++;
            b[x[i+1]][y[i+1]]++;
        }
    }

    out(N);
    rep(i, h*w) {
        if(a[x[i]][y[i]]%2 == 1 && i < h*w-1) {
            cout << x[i]+1 << " " << y[i]+1 << " " << x[i+1]+1 << " " << y[i+1]+1 << "\n";
            a[x[i+1]][y[i+1]]++;
        }
    }
    
    re0;
}

Measured memory_bytes: 9984