akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	// sc := bufio.NewScanner(os.Stdin)
	// sc.Scan()
	// line := sc.Text()
	var n int
	var a int
	var b int
	fmt.Scanf("%d %d %d", &n, &a, &b)

	var sum int
	for i := 1; i <= n; i++ {
		digitSum := digit_sum(i)

		if a <= digitSum && b >= digitSum {
			sum += i
		}
	}
	fmt.Println(sum)
}

func digit_sum(n int) int {
	if n < 10 {
		return n
	}
	return digit_sum(n/10) + n%10
}


Measured memory_bytes: 1832
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;	//using vi = vector<int>;

#define rep(i, N) for (int i = 0; i < N; i++)

int main()
{
	int n, d,ans=0;
	cin >> n >> d;

	vector<vector<int>> p(n,vector<int>(d));

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

	double temp;

	for (int i = 0; i < n-1; i++) {
		for (int j = i + 1; j < n; j++) {
			temp = 0;
			for (int k = 0; k < d; k++) {
				temp += pow(p[i][k] - p[j][k],2);
			}
			temp = sqrt(temp);
			//cout << "temp:" << temp << endl;
			if (ceil(temp) == floor(temp)) {
				ans++;
			}
		}
	}

	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/dp/tasks/dp_h

ll dp[10005][10005];

int main() {
  int H, W; cin >> H >> W;
  char a[H][W];
  REP(i, H) REP(j, W) cin >> a[i][j];

  dp[H][W] = 1;
  for (int i = H; i > 0; i--) {
    for (int j = W; j > 0; j--) {
      char A = a[i-1][j-1];
      if (A == '#') {
        dp[i][j] = 0;
      } else {
        dp[i][j] += (dp[i+1][j] + dp[i][j+1])%MOD;
      }
    }
  }
  cout << dp[1][1] << "\n";


  return 0;
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int A = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '1') A++;
  }
  cout << 2 * min(A, N - A) << endl;
}


Measured memory_bytes: 512
// D - Teleporter
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; ll K; cin>>N>>K;
	vi A(N);
	rep(i, N){ cin>>A[i];A[i]--; }
	vi cnt(N);
	int pre = 0;
	rep(i, N*2){ cnt[pre]++; pre = A[pre]; }
	int one, loops = one = 0;
	for(int c:cnt){
		if(c==1) one++;
		else if(c>1) loops++;
	}
	int k = max(0LL, K-one) % loops + min(K, (ll)one);
	pre = 0;
	while(k--) pre = A[pre];
	cout<< pre + 1 <<endl;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
// #define int long long int
#define mod 1000000007

void solve(string str1,string str2)
{
    string temp=str1;
    sort(temp.begin(),temp.end());
    int cnt=0,f1=0,f2=0;
    do {
        if(temp==str1)
            f1=cnt;
        if(temp==str2)
            f2=cnt;
        cnt++;
    } while(next_permutation(temp.begin(),temp.end()));

    cout<<abs(f1-f2)<<endl;
}

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

    int arr[n];
    string ff,ss;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        ff.push_back(arr[i]);
    }

    for(int i=0;i<n;i++){
        cin>>arr[i];
        ss.push_back(arr[i]);
    }

    // cout<<ff<<"   "<<ss<<endl;
    solve(ff,ss);
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long x1 = 0, y1 = 0, x2, y2, x3, y3;
    long S = scanner.nextLong();
    long n = 1;
    for (; n * n < S; n++);
    if (n * (n - 1) > S) {
      x2 = n;
      y3 = n - 1;
      y2 = 1;
      x3 = n * (n - 1) - S;
    } else {
      x2 = n;
      y3 = n;
      y2 = 1;
      x3 = n * n - S;
    }
    System.out.printf("%d %d %d %d %d %d\n", x1, y1, x2, y2, x3, y3);
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N;
string s[MAX];

int main(){
    cin >> N;
    rep(i, N) cin >> s[i];

    rep(i, N){
        sort(s[i].begin(), s[i].end());
    }

    sort(s, s+N);

    map<string, ll> m;
    rep(i, N){
        m[ s[i] ]++;
    }

    ll ans = 0;
    for(auto i : m){
        ans += (ll) i.second * (i.second - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 13568
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int l = scan.nextInt();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < n; i++) {
			list.add(scan.next());
		}
		Collections.sort(list);
		for(String s:list) {
			System.out.print(s);
		}
		System.out.println();
	}
}

Measured memory_bytes: 21972
#include <vector>
#include <iostream>
#include <map>

using namespace std;

const int NUM = 10;
const int INFTY = 1e9;

int cost[NUM][NUM];

int main(){
    int W,H;
    cin >> H >> W;
    for(int i=0;i<NUM;i++){
        for(int j=0;j<NUM;j++){
            cin >> cost[i][j];
        }
    }

    for(int k=0;k<NUM;k++){
        for(int i=0;i<NUM;i++){
            for(int j=0;j<NUM;j++){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
    map<int,int> wall;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int a; cin >> a;
            wall[a]++;
        }
    }
    int ans = 0;
    for(int i=0;i<10;i++){
        ans += cost[i][1] * wall[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
t = [int(input()) for i in range(n)]

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


print(lcm_list(t))

Measured memory_bytes: 5100
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define rep(i,a,b) for(register int i=(a);i<(b);++i)
#define pb push_back
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
	const uint32 Buffsize=1<<15,Output=1<<24;
	static char Ch[Buffsize],*S=Ch,*T=Ch;
	inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
	static char Out[Output],*nowps=Out;
	
	inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

	template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}

	inline void readmd(int&x)
	{
		x=0;static char ch;
		for(ch=getc();!isdigit(ch);ch=getc());
		for(;isdigit(ch);ch=getc())x=(x*10ll+(ch^48))%998244353;
	}
}
using namespace IO;

void file()
{
	FILE*DSD=freopen("water.in","r",stdin);
	FILE*CSC=freopen("water.out","w",stdout);
}

const int MAXN=1e5+7;

static int n,m,a[MAXN],b[MAXN];

inline void init()
{
	read(n),read(m);
	Rep(i,1,m)read(a[i]),read(b[i]);
}

static int fa[MAXN],sz[MAXN];

inline int Find(int u)
{return fa[u]==fa[fa[u]]?fa[u]:fa[u]=Find(fa[u]);}

static ll ans[MAXN],as;

inline void solve()
{
	Rep(i,1,n)fa[i]=i,sz[i]=1;
	as=(ll)n*(n-1)/2;
	Repe(i,m,1)
	{
		ans[i]=as;
		int u=Find(a[i]),v=Find(b[i]);
		if(u==v)continue;
		if(sz[u]>sz[v])swap(u,v);
		as-=(ll)sz[u]*sz[v];
		fa[v]=u,sz[u]+=sz[v];
	}
	Rep(i,1,m)write(ans[i]);
	flush();
}

int main()
{
	init();
	solve();
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using pint = pair<int, int>;

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

    vector<int> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];

    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());

    int z = 0;
    while (true)
    {
        if (x == 0 && y == 0)
            break;
        if (x == 0)
        {
            if (q[y - 1] < r[z])
            {
                --y;
                ++z;
                if (z == c)
                    break;
                continue;
            }
        }
        else if (y == 0)
        {
            if (p[x - 1] < r[z])
            {
                --x;
                ++z;
                if (z == c)
                    break;
                continue;
            }
        }
        else
        {
            if (p[x - 1] < q[y - 1])
            {
                if (p[x - 1] < r[z])
                {
                    --x;
                    ++z;
                    if (z == c)
                        break;
                    continue;
                }
            }
            else
            {
                if (q[y - 1] < r[z])
                {
                    --y;
                    ++z;
                    if (z == c)
                        break;
                    continue;
                }
            }
        }

        break;
    }

    ll ans = 0;
    rep(i, x) ans += p[i];
    rep(i, y) ans += q[i];
    rep(i, z) ans += r[i];

    cout << ans << endl;
}

Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

stack<P> st;
int a[200000];
signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld", &a[i]);
	int s = 0, ans = 0;
	
	drep(i,n-1,0){
		if(st.empty() or st.top().fi < a[i]){
			st.push(P(a[i], 1));
			s += a[i];
			ans += s;
			continue;
		}
		int cnt = 0;
		while(!st.empty() and a[i] < st.top().fi){
			P p = st.top();st.pop();
			s -= p.fi*p.se;cnt += p.se;
		}
		st.push(P(a[i], cnt+1));
		s += a[i]*(cnt+1);
		ans += s;
	}
	printf("%lld\n", ans);
	return 0;
}






Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];
    LL gcd = a[0];
    rep1(i, n) gcd = __gcd(gcd, a[i]);
    cout << gcd << endl;

}

Measured memory_bytes: 1024
import numpy as np


n,k = list(map(int, input().split()))

b =  k
a = n + 1
d = a - b
s = 0
i = 0
recs = []


while (a!=1):
    d = a - b
    if d >= 0:
        s += (d * 0.5 ** i)
        a = b
        recs.append([d, i])
#     print(a, b, i, d, s)
    b = b//2 + b%2
    i += 1
ans  = s/n

print(ans)

Measured memory_bytes: 12488
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
    int n, m;char c[100][100];cin >> n >> m;
    rep(i, n) {
        rep(j, m) {
            cin >> c[i][j];
        }
    }
    rep(i, n) {
        rep(k, 2) {
            rep(j, m) {
                cout << c[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
cs = Array.new(n + 1, 0)
i, x, y = 1, [], []
while cs[i] < 2
    (cs[i].zero? ? x : y) << i
    cs[i] += 1
    i = a[i - 1]
end
puts k < x.size ? x[k] : y[(k - x.size) % y.size]

Measured memory_bytes: 31744
# vim: ft=ruby

class Solver
  def prepare
    @d = gets.to_i
    @cs = gets.split(" ").map(&:to_i)
    @mans = []  # mans[date][contest]

    @last = [0] * 26

    @d.times do
      @mans << gets.split(" ").map(&:to_i)
    end
  end

  # ----------- #

  def score(contest_id, date)
    @mans[date][contest_id]
  end

  def decrease_per_contest(contest_id, date)
    @cs[contest_id] * (date - @last[contest_id])
  end

  def decrease_all(date)
    (0..25).map do |contest_id|
      decrease_per_contest(contest_id, date)
    end.sum
  end


  # TOOLS

  def evaluate(ts)
    res = 0
    ts.each.with_index do |t, d|  # d = date
      t -= 1
      res += score(t, d)
      @last[t] = d+1
      res -= decrease_all(d+1)
    end
    res
  end

  def random_contest
    (0..25).to_a.sample
  end

  def random_pattern
    @d.times.map { random_contest }
  end

  def uniform_pattern
    ((0..25).to_a * 20)[0, @d]
  end

  def print_result(pattern)
    pattern.each do |p|
      puts p+1
    end
  end

  def elapsed_time
    time_now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    time_now - $time_start
  end

  ALPHA = 0.6
  MAX_TIME = 2
  def temperature
    r = elapsed_time / MAX_TIME
    ALPHA ** r
  end

  def probability(e_prev, e_next)
    t = temperature

    if e_next > e_prev
      # if e_next is better, always move
      1
    else
      # temperature
      remaining_time = MAX_TIME - elapsed_time
      remaining_time ** 2
      # Math.exp((e_prev - e_next) / t)
    end
  end

  # TOOLS END

  def change_randomly(pattern)
    pattern = pattern.dup
    pos = random_contest
    pattern[pos] = random_contest
    pattern
  end

  def swap_randomly(pattern)
    pattern = pattern.dup
    pos = rand(@d-1)
    c = pattern[pos]
    pattern[pos] = pattern[pos+1]
    pattern[pos+1] = c
    pattern
  end

  def solve
    pattern = uniform_pattern
    e = evaluate(pattern)

    count = 0
    movecount = 0

    # namasu
    loop do
      count += 1
      break if elapsed_time > 1.87
      new_pattern = swap_randomly(pattern)
      e_next = evaluate(new_pattern)

      r = rand
      if r < probability(e, e_next)
        movecount += 1
        pattern = new_pattern
        e = e_next
      end
    end

    # end namasu

    if ENV['DEBUG']
      STDERR.puts movecount
      STDERR.puts count
    end

    print_result(pattern)
  end

end

$time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
solver = Solver.new
solver.prepare
solver.solve


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

int main(){
  int s;
  cin >> s;
  int count = 1;
  while (s > 4 || s == 3){
    if (s % 2 == 0){
      s /= 2;
    }
    else{
      s = 3 * s + 1;
    }
    count++;
  }
  cout << count + 3 << endl;
}


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

using namespace std;

const int N = 1003;
typedef long long ll;
typedef pair<int, int> ii;
int x, y, z, k, f[N][N];
ll a[N], b[N], c[N];

struct CompareII {
	bool operator()(const ii& u, const ii& v) {
		int x1 = u.first, y1 = u.second;
		int x2 = v.first, y2 = v.second;
		return b[x1] + c[y1] + a[f[x1][y1]] < b[x2] + c[y2] + a[f[x2][y2]];
	}
};

int main() {
	scanf("%d%d%d%d", &x, &y, &z, &k);
	for (int i = 1; i <= x; ++i) scanf("%lld", &a[i]);
	for (int i = 1; i <= y; ++i) scanf("%lld", &b[i]);
	for (int i = 1; i <= z; ++i) scanf("%lld", &c[i]);
	priority_queue<ii, vector<ii>, CompareII > heap;
	sort(a + 1, a + 1 + x, greater<ll>());
	sort(b + 1, b + 1 + y, greater<ll>());
	sort(c + 1, c + 1 + z, greater<ll>());
	for (int i = 1; i <= y; ++i)
		for (int j = 1; j <= z; ++j) {
			f[i][j] = 1;
			heap.push(ii(i, j));
		}
	while (k--) {
		ii t = heap.top(); heap.pop();
		int x1 = t.first, y1 = t.second;
		printf("%lld\n", b[x1] + c[y1] + a[f[x1][y1]]);
		if (f[x1][y1] < x) {
			f[x1][y1]++;
			heap.push(ii(x1, y1));
		}			
	}
	cerr << 1.0 * clock() / CLOCKS_PER_SEC;
	return 0;
}


Measured memory_bytes: 12652
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

// 1テヲツ鳴?・ツュツ耀plit ティツヲツ《stream
vector<string> split(const string &str, char delim) {
	istringstream iss(str); string tmp; vector<string> res;
	while(getline(iss, tmp, delim)) res.push_back(tmp);
	return res;
}

int main(void) {
	string s;

	while (true) {
		getline(cin, s);
		if (s == "END OF INPUT") break;
		
		vector<string> ws = split(s, ' ');
		for (auto w : ws) {
			cout << w.size();
		}
		cout << endl;
	}

	return 0;
}

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

typedef unsigned long long ll;
//ll mod = 1000000007;
#define mod 1000000007

ll pow(ll m, ll n){
	  if(n==0) return 1;
	  if(n%2==1)
			return ((pow(m,(n)/2) % mod) * (pow(m,(n)/2) % mod) % mod * (m % mod)) % mod;
	  else
			return ((pow(m,n/2) % mod) * (pow(m,n/2) % mod)) % mod;
}


ll mypow(ll m, ll n){
	  if(n==0) return 1;
	  if(n%2==1)	return mypow(m*m%mod,n/2) % mod * m % mod;
	  return mypow(m*m%mod,n/2) % mod;
}


int main(){

	  ll m,n; cin >> m >> n;
	  cout << pow(m,n)%mod << endl;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,hyo[11][11],n,wa[11],wa2[11],sum;
	while(1) {
		scanf("%d",&n);
		if(n==0)  break;
		for(i=0;i<n;i++) {
			for(j=0;j<n;j++) scanf("%d",&hyo[i][j]);
		}
		for(i=0;i<n;i++) {
			sum=0;
			for(j=0;j<n;j++) sum+=hyo[i][j];
			wa[i]=sum;
		}
		for(i=0;i<n;i++) {
			sum=0;
			for(j=0;j<n;j++) sum+=hyo[j][i];
			wa2[i]=sum;
		}
		for(i=0;i<n;i++) {
			for(j=0;j<n;j++) {
				printf("%5d",hyo[i][j]);
			}
			printf("%5d",wa[i]);
			printf("\n");
		}
		sum=0;
		for(i=0;i<n;i++) {
			printf("%5d",wa2[i]);
			sum+=wa2[i];
		}
		printf("%5d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1044
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0

for i in range(N):
  def meguru_bisect_A(ng, ok):
    def is_ok(idx):
      return A[idx] < B[i]

    while (abs(ok - ng) > 1):
      mid = (ok + ng) // 2
      if is_ok(mid):
        ok = mid
      else:
        ng = mid
    return ok

  def meguru_bisect_C(ng, ok):
    def is_ok(idx):
      return B[i] < C[idx]

    while (abs(ok - ng) > 1):
      mid = (ok + ng) // 2
      if is_ok(mid):
        ok = mid
      else:
        ng = mid
    return ok
  
  ans += (meguru_bisect_A(N, -1)+1) * (N - meguru_bisect_C(-1, N))

print(ans)

Measured memory_bytes: 29284
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
#define int long long 
signed main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  int x = 0,y = 0;
  for(int i = 0;i < 2 * n;i++){
  	if(i % 2 == 0){
  	  cout << s[x];
  	  x++;
  	}else{
  	  cout << t[y];
  	  y++;
  	}
  }
  return 0;
} 


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

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

	if (a < b)
		if (b < c)
			printf("Yes\n");
		else
			printf("No\n");
	else
		printf("No\n");

	
	

	return 0;
}


Measured memory_bytes: 2652
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n,m,a;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a;
        n -= a;
    }
    cout << (n >= 0? n: -1) << endl;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;
    Vi p(n), q(n);
    REP(i, n) cin >> p[i];
    REP(i, n) cin >> q[i];

    vector<int> v(n);
    REP(i, n) v[i] = i+1;
    int x = 1;
    int px, qx;
    do {
        bool pf = true, qf = true;
        REP(i, n) {
            pf = pf && (p[i] == v[i]);
            qf = qf && (q[i] == v[i]);
        }
        if (pf) px = x;
        if (qf) qx = x;
        x++;
    } while( next_permutation(ALL(v)) );

    std::cout << abs(px-qx) << '\n';

    return 0;
}


Measured memory_bytes: 256
S = input()
n = len(S)
pattern = []
total = 0
for i in range(2 ** (n - 1)):
    tmp = [''] * (n - 1)
    for j in range(n - 1):
        if i >> j & 1:
            tmp[j] = '+'
    pattern.append(tmp)

for i in range(2 ** (n - 1)):
    tmp = ''
    for j in range(n - 1):
        tmp += S[j] + pattern[i][j]
    tmp += S[n - 1]
    total += sum(list(map(int, tmp.split('+'))))

print(total)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>

int main(int argc, char *argv[]){
    int N, M;
    std::cin >> N >> M;
    if(M<=1){
        std::cout << 0 << std::endl;
        return 0;
    }
    if(N>=M){
        std::cout << 0 << std::endl;
        return 0;
    }

    std::vector<int> X(M);
    for(auto &x : X){
        std::cin >> x;
    }

    std::sort(X.begin(),X.end());
    int W = X[M-1] - X[0];
    if(N<=1){
        std::cout << W << std::endl;
        return 0;
    }

    std::vector<int> deltaX(M-1);
    for(int i=0; i<M-1; ++i){
        deltaX[i] = X[i+1]-X[i];
    }
    std::sort(deltaX.begin(),deltaX.end(),std::greater<int>());

    for(int i=0; i<N-1; ++i){
        W -= deltaX[i];
    }
    std::cout << W << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int N, K;
  cin >> N >> K;
  ll res = K;

  for (int i = 0; i < N - 1; i++) {
    res *= K - 1;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <functional>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
using namespace std;
 
#define pii pair<int, int>
#define rank asdf
 
const int mod = (int)1e9 + 7;

int a, b, c;

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> a >> b >> c;
    if(a + b + c >= 22) return cout << "bust\n", 0;
    cout << "win\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;

const int N = 1e5 + 5;
const int Mod = 1e9 + 7;

int n, m, x[N], y[N];
ll xx[N], yy[N], s;
ll ans, ans1;

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", x + i);
	for (int i = 1; i <= m; i++) scanf("%d", y + i);
	sort(x + 1, x + 1 + n);
	sort(y + 1, y + 1 + m);
	s = 0;
	for (int i = 1; i <= n; i++) {
		ans += (ll)x[i] * (i - 1) % Mod - s;
		ans %= Mod;
		s += x[i];
		s %= Mod;
	}
	s = 0;
	for (int i = 1; i <= m; i++) {
		ans1 += (ll)y[i] * (i - 1) % Mod - s;
		ans1 %= Mod;
		s += y[i];
		s %= Mod;
	}
	ans += Mod; ans %= Mod;
	ans1 += Mod; ans1 %= Mod;
	cout << ans * ans1 % Mod << endl;
}



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

int main() {
  int N;
  cin >> N;
  vector <int> l(N) , r(N);
  for(int i = 0; i < N; i++){
    cin >> l[i] >> r[i];
  }
  int answer = 0;
  for(int i = 0; i < N; i++){
    answer+=(r[i] - l[i] + 1); 
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
    int n, r;
    cin >> n >> r;
    if (n < 10) cout << r + (100 * (10 - n)) << endl;
    else cout << r << endl;
    return 0;
}

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

typedef long long ll;

const int maxn = 1e6+10, MOD = 1e9+7;
int n, h, d;
int a[maxn], sum, b[maxn], s[maxn], ans;

int main() {
	scanf("%d%d%d", &n, &h, &d);
	a[0] = 1;
	for (int i = 1; i <= n; ++i) {
		a[i] = (ll)a[i-1]*i%MOD;
		sum = (ll)(sum+a[i])%MOD;
	}
	for (int i = 1; i <= h; ++i) {
		b[i] = ((s[i-1]-((i-d-1<1)?0:s[i-d-1])+MOD)*(ll)sum+(i<=d))%MOD;
		s[i] = (s[i-1]+b[i])%MOD;
	}
	ans = (ll)b[h]*a[n]%MOD;
	printf("%d\n", ans);
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int H,W;
    int N;
    cin >> H >> W >> N;
    vector<int> wall[200002];
    for(int i=0;i<N;i++){
        int x,y;
        cin >> x >> y;
        wall[x].push_back(y);
    }
    wall[H+1].push_back(1);

    int y=1;
    for(int x=1;x<=H;x++){
        sort(wall[x+1].begin(), wall[x+1].end());
        if(wall[x+1].size()>0 && wall[x+1][0]<=y){
            cout << x << endl;
            return 0;
        }
        if(wall[x+1].size()==0 || wall[x+1][0]>y+1) y++;
    }
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define bc __builtin_popcount
#define MAXN 2000005
#define debug cout<<"we are debuuging"<<endl;
#define MOD 998244353
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int mark[MAXN];
int main()
{
    int x,n,y;
    cin>>x>>n;
    set<int> s;
    for(int i=0;i<n;i++)
     {cin>>y;
     s.in(y);}
     int val,mini=INT_MAX,ans=x;
    for(int i=x-101;i<=x+101;i++)
    {
      if(s.find(i)==s.end())
      {
           val=abs(x-i);
           if(val<mini)
           {
                ans=i;
                mini=val;
           }
      }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 3580
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
before_dish = -100000
for i in range(n):
    dish = A[i]
    ans += B[dish-1]
    if dish - before_dish == 1:
        ans += C[before_dish-1]
    before_dish = A[i]
print(ans)

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

int H, W;
const int MAX_HW = 50;
char S[MAX_HW][MAX_HW];

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

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }

    bool f;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            f = false;
            if (S[i][j] == '.') {
                f = true;
            }
            else {
                for (int k = 0; k < 4; k++) {
                    if (0 <= i + dy[k] && i + dy[k] < H &&
                        0 <= j + dx[k] && j + dx[k] < W) {
                            if (S[i+dy[k]][j+dx[k]] == '#') {
                                f = true;
                                break;
                            }
                    }
                }
            }

            if (!f) break;
        }
        if (!f) break;
    }

    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let mut s:Vec<char> = read::<String>().chars().collect();

    for _ in 0..15-s.len() {
        s.push('o');
    }
    println!("{}", if s.iter().filter(|&x| *x=='o').count() > 7 {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

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

    A.push_back(A.back());

    long long count = 0;
    long long sum = 0;

    for (int i = 0; i < N; i++) {
        sum += A[i];
        if (sum * 2 >= A[i + 1]) count++;
        else count = 0;
    }

    cout << count << endl;

    return 0;
}




















































































Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define ll long long
#define ld long double
//ソートのbegin,end省略
#define all(n) begin(n),end(n)
int main(){
  ll n; cin >> n;
  vector<tuple<string,ll,ll>> p;
  rep(i,n){
    string s; ll nt;
    cin >> s >> nt;
    p.emplace_back(s,-nt,i+1);
  }
  
  sort(all(p));
  
  for(auto v : p){
    cout << get<2>(v) << endl;
  }
}

Measured memory_bytes: 3600
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k - 1])

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

int main(){
	
	int n;
	
	cin >> n;
	
	int ans = 0;
	int c[n-1], a[n];
	
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	for (int i = 1; i <= n; i++){
		int b;
		cin >> b;
		ans+=b;
	}
	
	for (int i = 1; i <= n-1; i++){
		cin >> c[i];
	}
	
	for (int i = 1; i < n; i++){
		if (a[i+1] - a[i] == 1){
			ans+=c[a[i]];
		}
	}
	
	cout << ans;
}


Measured memory_bytes: 256
## coding: UTF-8
N,K = map(int,input().split())

d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split()))) 
#print(d)
#print(A)

have_not = [0] + [1] * N
for i in range(K):
    for j in range(len(A[i])):
        #print(A[i][j])
        have_not[A[i][j]] = 0

#print(have_not)
print(sum(have_not))



Measured memory_bytes: 67784
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			String line = in.nextLine();
			String decrypted = " ";
			for(int k = 0; k < 26; k++){
				decrypted = " ";
				for(int i = 0; i < line.length(); i++){
					char e = line.charAt(i);
					if(e != ' ' && e != '.'){
						char d = (char)((((e - 'a') + k) % 26) + 'a');
						decrypted += d;
					}
					else{
						decrypted += e;
					}
				}
				decrypted += ' ';
				if(decrypted.contains(" this ") || decrypted.contains(" that ") || decrypted.contains(" the ") ||
						decrypted.contains(" this. ") || decrypted.contains(" that. ") || decrypted.contains(" the. ")){
					break;
				}
			}
			//fix the extra spaces
			System.out.println(decrypted.substring(1, decrypted.length() - 1));
		}
	}

}

Measured memory_bytes: 16664
Q = int(input())

lim = 10**5+10
p = [True]*lim
p[0] = False
p[1] = False
for i in range(2, int(lim**0.5)+1):
    for j in range(i*2, 10**5+1, i):
        p[j] = False

y = [0]*lim
for i in range(3, lim, 2):
    y[i] = y[i-2]
    if p[i] and p[(i+1)//2]:
        y[i] += 1
    y[i-1] = y[i-2]

for _ in range(Q):
    l, r = map(int, input().split())
    print(y[r]-y[l-1])

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    vector<int> ar(n);
    vector<int> al(n);
    rep(i,n) cin >> ar[i] >> al[i];
    sort(ar.begin(),ar.end());
    sort(al.begin(),al.end());
    int ans = 0;
    if (n % 2 == 1){
        int a = ar[(n-1)/2];
        int b = al[(n-1)/2];
        ans += b - a + 1;
    }
    else {
        int a = ar[n/2 -1] + ar[n/2];
        int b = al[n/2 -1] + al[n/2];
        ans += b - a + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4760
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
      	String b = sc.next();
      	String c = sc.next();
      char x = a.charAt(a.length()-1);
      char y = b.charAt(0);
      char z = b.charAt(b.length()-1);
      char w = c.charAt(0);
      
	if(x==y&&z==w){System.out.println("YES");}
     else{System.out.println("NO");}
      
    }
}

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

int main(){
	int c1, c2, c3, c4;
	char c;
	c1 = c2 = c3 = c4 = 0;
	while((c = getchar()) != EOF){
		switch(c - '0'){
		case 1:
			c1++;
			break;
		case 2:
			c2++;
			break;
		case 3:
			c3++;
			break;
		case 4:
			c4++;
			break;
		}
	}
	if(c1 < 3 && c2 < 3 && c3 < 3 && c4 < 3) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N,K;
string S;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>K>>S;
    S[K-1]=tolower(S[K-1]);
    cout <<S<<"\n";
}

Measured memory_bytes: 256
package main
import (
  "fmt"
  "container/list"
)
const INF = 1<<30
func main() {
  var n int
  var s string
  fmt.Scan(&n)
  g := make([][]int,n)
  for i:=0;i<n;i++ {
    fmt.Scan(&s)
    for j,r := range s {
      if r == '1' {
        g[i] = append(g[i],j)
        g[j] = append(g[j],i)
      }
    }
  }
  color := make([]int,n)
  queue := list.New()
  ok := true
  color[0] = 1
  queue.PushBack(0)
  Bfs:
  for queue.Len() > 0 {
    i,_ := queue.Remove(queue.Front()).(int)
    for _,j := range g[i] {
      if color[j] == color[i] {
        ok = false
        break Bfs
      }
      if color[j] == 0 {
        color[j] = -color[i]
        queue.PushBack(j)
      }
    }
  }
  if !ok { fmt.Println(-1);return }
  d := make([][]int,n)
  for i:=0;i<n;i++ {
    d[i] = make([]int,n)
    for j:=0;j<n;j++ { d[i][j] = INF }
    for _,j := range g[i] { d[i][j] = 1 }
    d[i][i] = 0
  }
  for k:=0;k<n;k++ {
    for i:=0;i<n;i++ {
      for j:=0;j<n;j++ { d[i][j] = min(d[i][j],d[i][k]+d[k][j]) }
    }
  }
  m := 0
  for i:=0;i<n;i++ {
    for j:=0;j<n;j++ { m = max(m,d[i][j]+1) }
  }
  fmt.Println(m)
}
func min(x,y int) int {
  if x < y { return x }
  return y
}
func max(x,y int) int {
  if x > y { return x }
  return y
}

Measured memory_bytes: 2304
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	stack<int> s;
	string str;
	int a,b;
	while(cin>>str){
		if(str=="+"){
			a=s.top();
			s.pop();
			b=s.top();
			s.pop();
			s.push(a+b);
		}else if(str=="-"){
			a=s.top();
			s.pop();
			b=s.top();
			s.pop();
			s.push(b-a);
		}else if(str=="*"){
			a=s.top();
			s.pop();
			b=s.top();
			s.pop();
			s.push(a*b);
		}else{
			s.push(stoi(str));
		}
	}
	cout<<s.top()<<endl;
}

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

using namespace std;

int main()
{

    string s;
    cin>>s;

    long l=s.length();

    long i=0,j,k=0;
    string prev="";

    for(i=0;i<l;i++)
    {
        string temp="";


        while(i<l)
        {
            temp+=s[i];
            if(temp!=prev)
            {

                k++;
                prev=temp;
                break;
            }

            i++;
        }
    }

    cout<<k<<"\n";
}


Measured memory_bytes: 640
a=input()
a=int(a)
li1=[2,3,50,60,70,80,22,33,44,55,66,77,26,39,52,65,78,34,51,68,38,57,46,69,58,62,74,]
for i in range(4,82):
    b=0
    for k in range(2,i):
        if i%k==0:
            b=1
    if b==0:
        li1.append(i)
li2=[h for h in range(1,82)]
li3=list(set(li2)-set(li1))
li4=[2,3,5,7,9]
li5=li3+li4
if a in li5:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> 
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    string S;cin>>S;
    int ans = 0;
    int count = 0;
    REP(i,S.size()){
        if(S[i] =='A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T'){
            count++;
        }else{
            count = 0;
        }
        ans = max(ans,count);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<string> z(n);
    int i;
    for(i=0; i<n; i++) {
        char str[12]={0};
        scanf("%s", str);
        sort(str+0, str+10);
        z[i]=string(str);
    }
    sort(z.begin(), z.end());

    ll sum=0;
    int cnt=0;
    for(i=1; i<n; i++) {
        if(z[i-1]==z[i]) cnt++;
        else {
            sum += (ll)cnt*(cnt+1)/2;
            cnt=0;
        }
    }
    sum += (ll)cnt*(cnt+1)/2;
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 5760
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 100000;
	public static final int MAX_D = 15;
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		double[][] DP = new double[MAX + 1][MAX_D + 1];
		double[] ans = new double[MAX];
		
		DP[0][0] = 1;
		
		double sum = 0;
		for(int day = 0; day < MAX; day++){
			for(int suc = 0; suc < MAX_D; suc++){
				if(DP[day][suc] <= 0){
					continue;
				}
				
				sum += DP[day][suc] * Math.pow(0.5, suc);
				
				if(suc == 0){
					DP[day + 1][suc + 1] += DP[day][suc];
				}else{
					DP[day + 1][0]       += DP[day][suc] * (1 - Math.pow(0.5, suc));
					DP[day + 1][suc + 1] += DP[day][suc] * Math.pow(0.5, suc);
				}
			}
			
			ans[day] = sum;
		}
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			System.out.println(ans[n - 1]);
		}
	}

}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long n;
    cin>>n;
    long long a[n];


    rep(i,n){
        cin>>a[i];
    }
    long long sum=0;
    rep2(i,n-1){
        if(a[i]<a[i-1]){
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<sum<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 5148
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power( ll a, ll n, ll m){
  ll ans = 1;
  while(n){
  if(n&1)
  {
  ans *= a;
  ans%=m;
  }
  a*=a;
  n/=2;
  }
  return ans ;
} 


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){

 ll a;
 cin>>a;
 
 ll ans  =0 ;
 
 ll temp = a/500;
 a= a%500;
 ans += temp*1000;
 
 ans+= ( a - a%5);
 cout<<ans<<endl;




return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3612
s = input()

tmp_0 = s[0]
if tmp_0 == s[1]:
    if tmp_0 == s[2] or tmp_0 == s[3]:
        print("No")
    else:
        if s[2] == s[3]:
            print("Yes")
        else:
            print("No")
else:
    tmp_1 = s[1]
    if s[2] == tmp_0:
        if s[3] == tmp_1:
            print("Yes")
        else:
            print("No")
    elif s[2] == tmp_1:
        if s[3] == tmp_0:
            print("Yes")
        else:
            print("No")

    else:
        print("No")


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

int cmpstr(const void * a, const void * b){
    const char *x = a, *y = b;
    return strcmp(x,y);
}

int main(){
    int n, l;
    scanf("%d%d", &n, &l);
    char s[100][101];

    //printf("%p %p\n", s, s[1]);

    scanf("%*c");
    for (int i = 0; i < n; ++i){
        scanf("%[^\n]", s[i]);
        scanf("%*c");
    }

    qsort(s, n, sizeof(s[0]), cmpstr);

    for (int i = 0; i < n; ++i){
        printf("%s", s[i]);
    }
    printf("\n");



    return 0;
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  int tmp;
  tmp = A;
  A = B;
  B = tmp;
  
  tmp = A;
  A = C;
  C = tmp;
  
  cout << A << ' ' << B << ' ' << C << endl;

}

Measured memory_bytes: 256