akhauriyash/Code-Regression huggingface dataset:
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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
      .map(|e| e.parse().ok().unwrap()).collect()
}

fn format_output(xs: &Vec<String>) -> String {
    xs.join(" ")
}

fn get_number(card: &str) -> u32 {
    card.chars().nth(1).unwrap().to_digit(10).unwrap()
}

fn bubble_sort(n: usize, xs: &Vec<String>) -> String {
    let mut copied_xs = xs.clone();

    for i in 0..n {
        for j in ((i + 1)..n).rev() {
            if get_number(&copied_xs[j]) < get_number(&copied_xs[j - 1]) {
                let tmp = copied_xs[j].clone();
                copied_xs[j] = copied_xs[j - 1].clone();
                copied_xs[j - 1] = tmp;
            }
        }
    }

    format_output(&copied_xs)
}

fn selection_sort(n: usize, xs: &Vec<String>) -> String {
    let mut copied_xs = xs.clone();

    for i in 0..n {
        let mut minj = i;

        for j in i..n {
            if get_number(&copied_xs[j]) < get_number(&copied_xs[minj]) {
                minj = j;
            };
        };

        let tmp = copied_xs[i].clone();
        copied_xs[i] = copied_xs[minj].clone();
        copied_xs[minj] = tmp;
    }
    format_output(&copied_xs)
}

fn main() {
    let n: usize = read();
    let xs: Vec<String> = read_vec();

    let ans_bubble = bubble_sort(n, &xs);
    let ans_select = selection_sort(n, &xs);

    println!("{}", ans_bubble);
    println!("Stable");
    println!("{}", ans_select);
    println!("{}", if ans_bubble == ans_select { "Stable" } else { "Not stable" });
}



Measured memory_bytes: 5036
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int ans=-1000000003;
int sum;
int score;
int n;
int b;
int f[101][11];
int p[101][12];
int a[11];/*お姉さんの店が開いてるか開いてないか*/
/*全通り生成してみる*/
void func(void){
        score=0;
        for(int i=0; i<n; i++) {
                for(int j=0; j<10; j++) {
                        if(a[j]+f[i][j]==2) {
                                sum+=1;
                        }
                        b+=a[j];
                }
                score+=p[i][sum];
                sum=0;
        }
        if(b!=0) ans=max(ans,score);
}
void dfs(int pas){
        if(pas==10) {
                /*aが一つ完成したらfuncを呼び出す*/
                func();
                return;
        }
        else{/*aを全通りやるのに配列を一つずつ埋めていく*/
             /*まず一通り試すためにあるaを生成*/
                a[pas]=0;
                dfs(pas+1);
                a[pas]=1;
                dfs(pas+1);
        }
}
int main(){
        cin >> n;
        for(int i=0; i<n; i++) {
                for(int j=0; j<10; j++) {
                        cin >> f[i][j];
                }
        }
        for(int i=0; i<n; i++) {
                for(int j=0; j<11; j++) {
                        cin >> p[i][j];
                }
        }
        dfs(0);
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

typedef complex<double> P;

/*
 // a1,a2ツづーツ津環づゥツ陳シツ静シツづ1,b2ツづーツ津環づゥツ陳シツ静シツづ個古ーツ点ツ計ツ算
 P intersection_l(P a1, P a2, P b1, P b2)
 {
 	P a = a2 - a1; P b = b2 - b1;
 	return a1 + a * cross(b, b1-a1) / cross(b, a);
 }
 */

double cross(P a, P b)
{	return a.real() * b.imag() - b.real() * a.imag(); }
int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		vector<P> p(3);
		
		rep(i, 3) cin >> p[i].real() >> p[i].imag();
		
		// ツ陳点ツづーツ出ツつキ
		P c1((p[0] + p[1]) / 2.0), c2((p[1] + p[2]) / 2.0);
		
		// ツ法ツ静シツベツクツトツδ仰づーツ出ツつキ
		P u1((p[0] - p[1]) * P(0, 1)), u2((p[1] - p[2]) * P(0, 1));
		
		// ツ古ーツ点ツづーツ出ツつキ
		P crs(c1 + u1 * cross(u2, (c2 - c1)) / cross(u2, u1));
		
		// ツ板シツ径ツづーツ出ツつキ
		double r = abs(crs - p[0]);
		
		printf("%.3f %.3f %.3f\n", crs.real(), crs.imag(), r);
	}
}

Measured memory_bytes: 0
#include <iostream> 
#include <string> 
using namespace std; 
int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) cout << a - 1 << " " << b;
    else
		cout << a << " " << b - 1;  
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int a,b,c; cin >> a >> b >> c;
    cout << (a+b+c-max(a,max(b,c))-min(a,min(b,c)))*min(a,min(b,c))/2 << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= n / 4 + 1; i++) {
		for (int j = 0; j <= n / 7+1; j++) {
			if (4 * i + 7 * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

if flag==1:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9172
H, W, K = map(int, input().split())
    
A = []
for h in range(H):
    s = input()
    A.append(s)

ans = 0
for h in range(1<<H):
    for w in range(1<<W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (h & (1<<i)) == 0 and (w & (1<<j)) == 0:
                    if A[i][j] == '#':
                        cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9124
n = int(input())
l = []
for i in range(1,n+1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0 :
        pass
    elif i % 5 == 0 :
        pass
    else:
        l.append(i)
print(sum(l))
        
        

Measured memory_bytes: 29964
//Kaori Miyazono, did I reach you ?
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
                        
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin >> s;
	for(int i = 0; i < s.size() - 1; i++){
		if ( s[i] == 'A' && s[i + 1] == 'C' ){
			cout << "Yes";
			return 0;
		}
	}	
	cout << "No";
	return 0;	
}         






Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int h, w;
	while (cin >> h >> w && (h != 0 && w != 0)) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 || i == h-1 || j == 0 || j == w-1) {
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		vector<int> v(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		long long res = 0, sum = v[0];
		for (int i = 1; i < n; i++) {
			res += sum;
			sum += v[i];
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	int N,T,A;
	int x;
	double *H;
	double min = 999999999;
	int index = -1;
	cin >> N >> T >> A;

	H = new double[N];
	for(int i=0;i<N;i++)
	{
		cin >> x;
		H[i] = T - x*0.006;
	}

	for(int i=0;i<N;i++)
	{
		//cout << H[i] << " ";
		if( min > abs(A - H[i]))
		{
			min = abs(A - H[i]);
			index = i+1;
		}
	}

	cout << endl << index << endl;

	delete(H);

	return 0;
}

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





int main() {
  string x,y;
  cin>>x>>y;
  
  if (x<y){
    cout<<'<'<<endl;
  }
  else if (x>y){
    cout<<'>'<<endl;
  }
  else {
    cout<<'='<<endl;
  }
    
    
    
    
  
}

  













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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

}

Node treeMaximum(Node x){

}

Node treeSearch(Node u, int k){

}

Node treeSuccessor(Node x){

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while( x != NIL ){
     y = x;
     if ( z->key < x->key ){
       x = x->left;
     } else {
       x = x->right;
     }
   }

   z->parent = y;
   if ( y == NIL ){
     root = z;
   } else {
     if (z->key < y->key) {
       y->left = z;
     } else {
       y->right = z;
     }
   }
}

void inorder(Node u){
  if ( u == NIL ) return;
   inorder(u->left);
   printf(" %d", u->key);
   inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25136
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < (n); i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define REPEACH(itr, k) for (auto &&itr : k)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;


const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans=0;
    ll now;
    cin >> now;
    REP(i,n-1){
        ll x;
        cin >> x;
        ans+=min((x-now)*a,b);
        now=x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		long n = sc.nextLong();
		//long m = sc.nextLong();

		if(n/100==n%10) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		//System.out.println((n-1)*(m-1));
	}
}




Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<pair<int,int>> b;
    rep(i,n) b.push_back({a[i],i+1});
    sort(b.begin(),b.end());
    
    rep(i,n) cout << b[i].second << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 2164
#!/usr/bin/env python3
import sys


def solve(N: int, H: "List[int]"):
    ma, ans = 0, 0
    for h in H:
        if ma <= h:
            ans += 1
            ma = h
    return ans


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, H))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};
 
//debug
//--------------------------------------------
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//roop
//--------------------------------------------
#define rep(i,s,n) for(LL i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

int main(){
    int N, K;
    cin >> N >> K;

    cout << K * int(pow((K-1), (N-1))) << endl;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin >> n >> k;
    vector<int> vec(k);
    for(int i = 0; i < k;i++) cin >> vec[i];
    auto acceptable_num = [&vec](int n) -> bool {
          int rem = 0;
          while(n!=0){
             rem = n % 10;
            n = n /10; 
              if(find(vec.begin(), vec.end(), rem) != vec.end()){
                  return false;
              }
          } 
        return true;
    };
    
    while(true){
       if(acceptable_num(n) == true){
         cout << n << endl; 
           break;
       } 
        n++;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java .util.Scanner;
public class Main{
    public static void main (String[] args){
        try(Scanner sc = new Scanner(System.in)){
            final int n = sc.nextInt();
            int i =1;
            do{
                int x = i;
                if(x%3 == 0){
                    System.out.print(" "+ i);
                }else{
                    do{
                        if(x%10  == 3){
                            System.out.print(" "+ i);
                            break;
                        }
                        x /= 10;
                    }while(x != 0);
                }
            }while(++i <= n);
            System.out.println();
        }
    }
}

Measured memory_bytes: 28828
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 3");
            WillReturn.Add("abc");
            WillReturn.Add("arc");
            //#####
            //#abc#
            //#arc#
            //#####
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 1");
            WillReturn.Add("z");
            //###
            //#z#
            //###
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int H = wkArr[0];
        int W = wkArr[1];

        var sb = new System.Text.StringBuilder();
        sb.AppendLine(new string('#', W + 2));

        foreach (string EachStr in InputList.Skip(1)) {
            sb.Append('#');
            sb.Append(EachStr);
            sb.Append('#');
            sb.AppendLine();
        }
        sb.AppendLine(new string('#', W + 2));
        Console.Write(sb.ToString());
    }
}


Measured memory_bytes: 13396
use std::io::stdin;

fn main () {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let mut t = String::new();
    stdin().read_line(&mut t).unwrap();
    let n: i64 = n.trim().parse().unwrap();
    let t: Vec<i64> = t.trim().split_whitespace().map(|i|i.parse().unwrap()).collect();

    let f = || {
        t.iter().fold(0, |acc, &i| acc + i - 1)
    };

    println!("{}", f());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
    int i,l,ck=0;
     string s;
    cin>>s;
    for(i=0;i<6;i++){
        if(s[2]==s[3] && s[4]==s[5]){
          ck=1;
        }
    }
        if(ck==1){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }

 return 0;
}

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

using namespace std;

int main(void){
    string s;
    cin >> s;
    
    int n = s.size();
    
    for (int i = 0; i < n; i++){
        if (s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

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

int main(void)
{
    int k;
    cin >> k;

    ll ans = 0;
    for(int a = 1; a <= k; a++) {
        for(int b = 1; b <= k; b++) {
            for(int c = 1; c <= k; c++) {
                ans += gcd(a, gcd(b, c));    
            }
        }
    }

    cout << ans << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
//#include <string>
using namespace std;
int main(){

    int r,c;
    cin>>r>>c;
    int hyou[r+1][c+1];
    for(int i=0;i<r;i++){
        int sum=0;
        for(int j=0;j<c+1;j++){
            if(j!=c){
                cin>>hyou[i][j];
                sum+=hyou[i][j];
            }else{
                hyou[i][j]=sum;
            }
        }
    }
    for(int i=0;i<c+1;i++){
      int  sum=0;
        for(int j=0;j<r+1;j++){
            if(j!=r){
                sum+=hyou[j][i];
            }else{
                hyou[j][i]=sum;
            }
        }
    }
    
    
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
           if(j!=c) cout<<hyou[i][j]<<' ';
           else cout<<hyou[i][j]<<endl;
        }
    }
    
    
    
    
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {

  int N, R;
  cin >> N >> R;

  int r = R;
  if (N < 10) {
    r += 100 * (10 - N);
  }

  cout << r << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    a: [Usize1; n]
    }
    let mut c = vec![0; n];
    for i in 0..n {
        c[a[i]] += 1;
    }
    let s = c.iter().map(|&x| (x * x - x) / 2 ).sum::<usize>();
    for i in 0..n {
        let ans = s - (c[a[i]] - 1);
        println!("{}", ans);
    }
}

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

int main(){
  int T;
  cin>>T;

  while(T--){
    string s;
    int ans = 0;
    int out = 0;
    bool first=false,second=false,third=false;

    while(cin>>s){
      if(s == "HIT"){
        if(third) ans++;
        third = second;
        second = first;
        first = true;
      }
      else if(s == "OUT"){
        out++;
        if(out == 3) break;
      }
      else{
        ans += first + second + third + 1;
        first = second = third = false;
      }
    }

    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w;
    while (cin>>h>>w) {
        if (h==0&&w==0) {
            break;
        } else {
            int sum=0;
            int min=100000;
            int min_h=100000;
            int ans_h,ans_w;
            sum+=h*h+w*w;
            for (int i=1;i<150;i++) {
                for (int j=i+1;j<=150;j++) {
                    if (sum<i*i+j*j) {
                        if (min>i*i+j*j) {
                            min=i*i+j*j;
                            ans_h=i;
                            ans_w=j;
                        }
                    } else if ( (sum==i*i+j*j)&&(i!=h&&j!=w) ) {
                        if (min_h>i&&i>h) {
                            min=i*i+j*j;
                            min_h=i;
                            ans_h=i;
                            ans_w=j;
                        }
                    }
                }
            }
            cout<<ans_h<<" "<<ans_w<<endl;
        }
    }
}



Measured memory_bytes: 3112
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		ArrayList<Integer> a = new ArrayList<Integer>();
		ArrayList<Integer> b = new ArrayList<Integer>();


		for(int i=0;i<n;i++) {
			a.add(sc.nextInt());
			b.add(sc.nextInt());
		}

		Collections.sort(a);
		Collections.sort(b);

		if(n%2==0) {
			double min = ((double)(a.get(n/2-1)+a.get(n/2)))/2;
			double max = ((double)(b.get(n/2-1)+b.get(n/2)))/2;
			System.out.println((int)((max-min)/0.5)+1);
		}else {
			double min = a.get(n/2);
			double max = b.get(n/2);
			System.out.println((int)(max-min)+1);
		}

	}


	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 70032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

const int maxn = 1e6 + 5;
int p[maxn];

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

  ll a, b;
  cin >> a >> b;
  int cnt = 1;
  memset(p, 1, sizeof p);
  ll g = __gcd(a, b);
  for(ll i = 2; i < maxn; i++){
    if(p[i]){
      for(ll j = i * i; j < maxn; j += i)
        p[j] = 0;
    }
  }
  for(ll i = 2; i * i <= g; i++){
    if(p[i] && (g % i == 0)){
      while(g > 1 && (g % i == 0)){
        g /= i;
      }
      cnt++;
    }
  }
  cnt += (g > 1);
  cout << cnt;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"

//region Template
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;

using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 3e3 + 6;
string s;
int r[MAXN];
int p[MAXN];
int n, m;

ll dp[MAXN][MAXN];

int ones(int l, int r){
	return p[r] - p[l - 1];
}

ll solve(int l, int c){
	if(l == n && c <= 1){
		return dp[l][c] = 1;
	}
	else if(l == n) return 0;

	if(dp[l][c] != 0) return dp[l][c];

	int nc = c + ones(r[l] + 1, r[l + 1]);
	int len = r[l] - l + 1;
	if(len > c) {
		dp[l][c] += solve(l + 1, nc);
	}
	if(c > 0) dp[l][c] += solve(l + 1, nc - 1);

	return dp[l][c] % MOD;
}

int main() {
	#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
	#endif

	cin >> n >> m;

	cin >> s;
	s = "#" + s;

	p[1] = (s[1] == '1');
	for(int i = 2; i <= n; i++){
		p[i] = p[i - 1] + (s[i] == '1');
	}

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

	for(int i = 0; i < m; i++){
		int l, x;
		cin >> l >> x;

		r[l] = max(r[l], x);
	}

	for(int i = 2; i <= n; i++){
		r[i] = max(r[i], r[i - 1]);
	}

	memset(dp, 0, sizeof dp);
	cout << solve(1, ones(1, r[1]));
}


Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
#define mx 500
typedef long long L;
L n,k;
long double fun(L x){
	L id=0;
	double res=1.0;
	while(x<k){
		x=x*2;
		res=(res*(.5));
	}
	res=(res*(1.0/(double)n));
	return res;
}
void solve(){
	double sum=0.0;
	for(L i=1;i<=n;i++){
		sum=sum+(fun(i));
	}
	printf("%.12f\n",sum);
}
int main()
{
	scanf("%I64d%I64d",&n,&k);
	solve();
	return 0;
}
/// %I64d  scanf(" %I64d ",&n);

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e10,dp1[1000001];
int num[10];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {    
       string s;
       cin>>s;
       int sum=0;
       for(int i=0;i<s.length();i++)
       {
           sum+=s[i]-'0';
       }
       if(sum%9==0)
       cout<<"Yes";
       else
       cout<<"No";
    }
 
}
// 🍪 🍪 🍪

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

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

    int button[2], both = 0, decrease = 0, temp1, temp2;
    cin >> button[0] >> button[1];
    temp1 = button[0];
    temp2 = button[1];
    both = button[0] + button[1];
    decrease = max((button[0]-1)+temp1, temp2+(button[1]-1));
    cout << max(both, decrease);

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define MOD 1000000007
using namespace std;
char str[10001];
int d,f[10001][100],len,limited[10001],remain[10001];
long long ans;
int main()
{
	scanf("%s",str);
	scanf("%d",&d);
	len=strlen(str);
	limited[0]=1;remain[0]=0;
	for(int i=0;i<len;i++)
	{
		for(int j=0;j<d;j++)
			for(int l=0;l<10;l++)
				f[i+1][(j+l)%d]=(f[i+1][(j+l)%d]+f[i][j])%MOD;
		for(int j=0;j<str[i]-'0';j++) f[i+1][(remain[i]+j)%d]=(limited[i]+f[i+1][(remain[i]+j)%d])%MOD;
		limited[i+1]=limited[i]; remain[i+1]=(remain[i]+str[i]-'0')%d;
	}
	ans=f[len][0]-1;
	if(!remain[len]) ans++;
	ans=(ans+MOD)%MOD;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main() {
    int N, Y;
    cin >> N >> Y;
    
    for (int i=0; i<=N; i++) {
        for (int j=0; j<=N-i; j++) {
            if (Y == 10000*i + 5000*j + 1000*(N-i-j)) {
                cout << i << " " << j << " " << N-i-j << endl;
                return 0;
            }
        }
    }
    
    cout << -1 << " " << -1 << " " << -1 << endl;
        
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int N;
    ll d[55];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }

    ll res = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            res += d[i] * d[j];
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

const int INF = 7+(1e+9);
typedef int Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

//引数 g:隣接リスト,s:始点,dist:各頂点までの距離が入る(経路に負閉路を含む場合,負の無限大となる),prev:最短路木の親頂点が入る
//戻値 なし
void shortestPath(const Graph &g,int s,vector<Weight> &dist,vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q;
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(auto f=g[e.dst].begin();f!=g[e.dst].end();f++){
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}

int main(){
  ll n,m;
  cin>>n>>m;
  vector<set<ll> >e1(n);
  vector<set<ll> >ee1(n);
  vector<set<ll> >e2(n);
  vector<set<ll> >e3(n);
  ll uu,vv;
  vector<ll>v(m,0);
  vector<ll>u(m,0);
  for(ll i=0;i<m;i++){
    cin>>uu>>vv;
    uu--;
    vv--;
    u[i]=uu;
    v[i]=vv;
    e1[uu].insert(vv);
    ee1[vv].insert(uu);
  }
  ll s,t;
  cin>>s>>t;
  s--;
  t--;
  Graph g(n*3);
  for(ll i=0;i<n;i++){
    for(auto j=e1[i].begin();j!=e1[i].end();j++){
      g[i*3].push_back(Edge(i*3,*j*3+1,1));
      g[i*3+1].push_back(Edge(i*3+1,*j*3+2,1));
      g[i*3+2].push_back(Edge(i*3+2,*j*3,1));
    }
  }
  vector<Weight> dist;
  vector<int> prev;
  shortestPath(g,s*3,dist,prev);
  ll ans=dist[t*3];
  if(ans==INF)ans=-1;
  else ans/=3;
  cout<<ans<<endl;
}


Measured memory_bytes: 39928
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    for i in range(int((len(S) - 1) / 2)):
        if not (S[i] == S[int((len(S) - 1) / 2) - 1 - i] and S[i] == S[int((len(S) - 1) / 2) + 1 + i] and S[i] == S[len(S) - 1 - i]):
            print(NO)
            return
    print(YES)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<utility>
#define rep(i,a) for( int i = 0; i != (a); ++i )

typedef std::pair<int, int> P;

const int MAX_N = 1 << 17, INF = 1 << 30;

int sz;
P dat[2*MAX_N-1];

void init( int n )
{
	sz = 1;
	while( sz < n )
		sz <<= 1;

	rep( i, 2*sz-1 )
		dat[i] = P( INF, INF );

	return;
}

void update( int k, P p )
{
	k += sz-1;
	dat[k] = p;

	while( k > 0 )
	{
		k = (k-1)>>1;
		dat[k] = std::min( dat[2*k+1], dat[2*k+2] );
	}

	return;
}

P query( int a, int b, int k, int l, int r )
{
	if( b <= l || r <= a )
		return P( INF, INF );

	if( a <= l && r <= b )
		return dat[k];
	else
		return std::min( query( a, b, 2*k+1, l, (l+r)>>1 ), query( a, b, 2*k+2, (l+r)>>1, r ) );
}

int N, R, L;
int cnt[MAX_N];

int main()
{
	scanf( "%d%d%d", &N, &R, &L );

	init( N );
	rep( i, N )
		update( i, P( 0, i ) );
	
	int prvT = 0;
	rep( i, R )
	{
		int d, t, x;
		scanf( "%d%d%d", &d, &t, &x );

		if( prvT != t )
			cnt[query( 0, N, 0, 0, sz ).second] += t - prvT;

		--d;
		P p = query( d, d+1, 0, 0, sz );
		update( d, P( p.first - x, p.second ) );
		prvT = t;
	}

	if( L != prvT )	
		cnt[query( 0, N, 0, 0, sz ).second] += L - prvT;
	
	printf( "%d\n", std::max_element( cnt, cnt+N )-cnt+1 );

	return 0;
}

Measured memory_bytes: 3468
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

struct problem {
	ll l, r;
	problem() = default;
	problem(ll a, ll b) { l = a, r = b; }
};

int N;
problem pr[100000 + 100];

ll a[100000 + 10] = {}, b[100000 + 10] = {};


int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> pr[i].l >> pr[i].r;

	sort(pr, pr + N, [](problem a, problem b) {
		if (a.l != b.l)return a.l < b.l;
		else return a.r > b.r;
	});

	int p = 0, q = 0;//pは再左端のrを持つ区間番号　qは再右端のlを持つ区間番号
	for (int i = 1; i < N; i++) {
		if (pr[p].r > pr[i].r)p = i;
	}
	for (int i = 1; i < N; i++) {
		if (pr[q].l < pr[i].l)q = i;
	}
	ll ans = 0;
	
	//pとqを1つの集合に入れる
	ans += max(0LL, pr[p].r - pr[q].l + 1);
	ll largest = 0;
	for (int i = 0; i < N; i++) {
		if (i == p || i == q)continue;
		largest = max(largest, pr[i].r - pr[i].l + 1);
	}
	ans += largest;

	//pとqを別々の集合に入れる。a[i] := i個p以外を含んで、その時点での結果
	a[0] = pr[p].r - pr[p].l;
	ll m = pr[p].l;
	for (int i = 1; i <= N; i++) {
		m = max(m, pr[i - 1].l);
		a[i] = max(0LL, pr[p].r - m + 1);
	}

	b[0] = pr[q].r - pr[q].l;
	ll M = pr[q].r;
	for (int i = 1; i <= N; i++) {
		M = min(M, pr[N - i].r);
		b[i] = max(0LL, M - pr[q].l + 1);
	}
	
	for (int i = 0; i <= N; i++)ans = max(ans, a[i] + b[N - i]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main()
{
  int x, y, t, ans=1;

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

  if( x < y ){
    t = x;
    x = y;
    y = t;
  }

  while( x % y != 0 ){
      ans = x % y;
      x = y;
      y = ans;
  }

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

  return 0;
}

Measured memory_bytes: 592
def binarySearch(list,key,n)
	left = 0
	right = n
	while left < right 
		mid = (left + right) / 2
		if list[mid] == key
			return mid
		elsif key < list[mid]
			right = mid
		else
			left = mid + 1
		end
	end
	return false

end

n1 = gets.to_i

list1 = gets.split.map(&:to_i)

n2 = gets.to_i
list2 = gets.split.map(&:to_i)
ans = 0
list2.each do |obj|
	tmp = binarySearch(list1,obj.to_i,n1)
	if tmp
		ans += 1
	end
end

puts ans

Measured memory_bytes: 17260
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val G = Array.fill(N + 1)(List[(Int, Int)]())
    (0 until N - 1) foreach { i =>
      val a, b = sc.nextInt()
      G(a) ::= (b, i)
      G(b) ::= (a, i)
    }

    // Gの'辺'を何色かで塗り分ける
    // 各頂点について, その頂点を端点に持つ辺の色が全て相異なるようにしたい
    // つまり, ある頂点を見たときに, その頂点から生えている辺は全て違う色である必要がある
    // 木なので, そのさらに次の頂点では, 既に使っている1色以外を再利用してふり直せばいい
    // 通ってきた辺の色を受け取っておけば良い. スタート時には, 0(undefined) からきたことにする
    // 来たところから戻らないようにする
    def solve(N: Int, G: Array[List[(Int, Int)]]): (Int, Array[Int]) = {
      val color = new Array[Int](N - 1)
      val visited = new Array[Boolean](N + 1)
      def dfs(stack: List[(Int, Int)], K: Int): Int =
        if (stack.nonEmpty) {
          val (u, c) = stack.head
          visited(u) = true
          val (next, colors) =
            G(u).foldLeft((stack.tail, 1))((state, v) =>
              if (!visited(v._1)) {
                if (state._2 == c) {
                  color(v._2) = state._2 + 1
                  ((v._1, state._2 + 1) :: state._1, state._2 + 2)
                } else {
                  color(v._2) = state._2
                  ((v._1, state._2) :: state._1, state._2 + 1)
                }
              } else state)
          dfs(next, K max (colors - 1))
        } else K
      (dfs((1, 0) :: Nil, 0), color)
    }

    val (k, c) = solve(N, G)
    println(k)
    println(c.mkString("\n"))
  }

}


Measured memory_bytes: 82260
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	string S[3];
	FOR(i,0,3) cin >> S[i];

	string ans = { S[0][0], S[1][0], S[2][0] };
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#import numpy as np
#import math
#from decimal import *
#from numba import njit
import re

#@njit
def main():
    S = input()
    T = input()

    if re.match(r'^[a-z]*$', S) and\
        re.match(r'^[a-z]*$', T) and\
        1 <=len(S) and\
        len(S) <= 10 and\
        len(T) == len(S) + 1 and\
        T[0:len(T)-1] == S:
        print('Yes')
    else:
        print('No')
    

main()


Measured memory_bytes: 9868
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int Y, M, D, ans = 0;
		cin >> Y >> M >> D;
		if(Y % 3 == 0 || M % 2 == 1) ans += 20 - D;
		else ans += 19 - D;
		for(int j = M+1; j <= 10; j++){
			if(Y % 3 == 0 || j % 2 == 1) ans += 20;
			else ans += 19;	
		}
		for(int j = Y+1; j <= 999; j++){
			if(j % 3 == 0) ans += 200;
			else ans += 195;	
		}
		cout << ans+1 << endl;
	}	
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
         
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
const int N = 100001; 


void solve(){
    int n;cin>>n;
    vi a(n);
    int mx=0,ans=0;
    rep(i,0,n){
    	cin>>a[i];
    	if(a[i]<mx)ans+=(mx-a[i]);
    	else mx=a[i];
    }
    cout<<ans;
    return;
}
         
signed main(){
        IOS;    
        

        int t=1;
        // cin>>t;
        // fac[0] = 1; 
        // for (int i=1 ; i<=2000001; i++) fac[i] = fac[i-1]*i%mod; 
        rep(i,0,t){
            solve();
            cout<<"\n";
        //   cout<<" * "<<t<<"\n";
        }
    //    return 0;
}

Measured memory_bytes: 4768
H, W = map(int, input().split())
pic = [[i for i in input()] for j in range(H)]
ans = [["#" for i in range(W+2)] for j in range(H+2)]

for h in range(H):
    for w in range(W):
        ans[h+1][w+1] = pic[h][w]
        
for i in range(H+2):
    for j in range(W+2):
        print(ans[i][j], end="")
    print()

Measured memory_bytes: 4596
import java.util.*;

class Main{

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }

    public Main(){
        Scanner scanner = new Scanner(System.in);
        int N;
        N = Integer.parseInt(scanner.next());

        int min = Integer.MAX_VALUE;

        int result = 0, in;
        for(int i=0;i<N;i++){
            in = Integer.parseInt(scanner.next());
            if(min >= in){
                result++;
                min = in;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 51196
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Hamza Hasbi
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        B_Snake_Toy solver = new B_Snake_Toy();
        solver.solve(1, in, out);
        out.close();
    }

    static class B_Snake_Toy {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int ans = 0;
            Comparator<Integer> cmp = (Integer a, Integer b) -> b.compareTo(a);
            PriorityQueue<Integer> tr = new PriorityQueue<>(cmp);
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                tr.add(a);
            }
            while (k > 0 && !tr.isEmpty()) {
                ans += tr.poll();
                k--;

            }
            out.printLine("\n" + ans);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void printLine(String s) {
            writer.println(s);
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 26708
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int main(void) {
	int x, y;
	cin >> x >> y;
	int ans = 0;
	int yy = abs(y);
	int xx = abs(x);
	if ((yy > xx&&x<0) || (xx>yy&&x > 0))ans += 1;
	ans += abs(yy - xx);
	if ((yy > xx&&y<0) || (xx>yy&&y > 0))ans += 1;
	if (y == -x)ans += 1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import sys
N,M=map(int,input().split())
S=input()
lst=[]
koma=N
rs=0
ME=0
pn=0
while koma>0 and pn==0:
 rs+=1
 if int(S[koma-rs])==0:
  ME=rs
 if koma-rs==0 or rs==M:
  lst.append(ME)
  if ME==0:
   pn+=1
  koma-=ME
  rs=rs-ME
  ME=0
if pn>0:
 print(-1)
else:
 lst.reverse()
 print(*lst)


Measured memory_bytes: 48476