akhauriyash/Code-Regression huggingface dataset:
class ArrayDeque:
    def __init__(self):
        self.a_size = 1
        self.a = [None]
        self.n = 0
        self.head = 0
        self.tail = 0

    def __bool__(self):
        return self.n != 0

    def _resize(self):
        new_a = [None] * ((self.n + 1) << 1)
        for i in range(self.n):
            new_a[i] = self.a[(self.head + i) & (self.a_size - 1)]
        self.a = new_a
        self.a_size = (self.n + 1) << 1
        self.head = 0
        self.tail = self.n

    def append(self, val):
        if self.n == self.a_size - 1:
            self._resize()
        self.a[self.tail] = val
        self.tail = (self.tail + 1) & (self.a_size - 1)
        self.n += 1

    def appendleft(self, val):
        if self.n == self.a_size - 1: 
            self._resize()
        self.head = (self.head - 1) & (self.a_size - 1)
        self.a[self.head] = val
        self.n += 1

    def popleft(self):
        if self.n == 0:
            raise IndexError()
        val = self.a[self.head]
        self.head = (self.head + 1) & (self.a_size - 1)
        self.n -= 1
        if self.a_size >= 4 * self.n + 2:
            self._resize()
        return val

    def pop(self):
        if self.n == 0:
            raise IndexError()
        self.tail = (self.tail - 1) & (self.a_size - 1)
        val = self.a[self.tail]
        self.n -= 1
        if self.a_size >= 4 * self.n + 2:
            self._resize()
        return val


n, q = map(int, input().split())
info = [input().split() for i in range(n)]

que = ArrayDeque()
for name, time in info:
    que.append((name, int(time)))

ans_time = 0
ans = []
while que:
    name, time = que.popleft()
    if time > q:
        que.append((name, time - q))
        ans_time += q
    else:
        ans_time += time
        ans.append((name, ans_time))

for name, time in ans:
    print(name, time)


Measured memory_bytes: 24976
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int a, b;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> a >> b;
	cout << (b - 1 + a - 2) / (a - 1) << "\n";
}

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

using namespace std;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string S;
	cin >> S;
	int ans = 1;
	vector<long long> pos;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'R') {
			pos.push_back(i);
		}
	}
	if (pos.size() == 0) {
		cout << 0 << endl;
	}
	else if (pos.size() == 1) {
		cout << 1 << endl;
	}
	else {
		for (long long i = 1; i < pos.size(); i++) {
			if (pos[i - 1] + 1 == pos[i]) {
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

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

	string s;
	cin >> s;

	int ans = 0;
	for(int i = 0; i < s.size() - 1; i++) {
		ans += s[i] != s[i + 1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
class PriorityQueue
  MIN = -(1 << 60)

  attr_reader :size

  def initialize(&block)
    @size = 0
    @heap = Array.new
    @get_key = block || :itself.to_proc
  end

  def empty?
    size == 0
  end

  def pop
    return nil if @size <= 0
    max = @heap[1]
    @heap[1] = @heap[@size]
    @size -= 1
    max_heapify(1)
    max
  end

  def push(x)
    @size += 1
    i = @size
    @heap[i] = x
    while i > 1 && (@get_key.call(@heap[i / 2]) <=> @get_key.call(@heap[i])) < 0
      t = @heap[i / 2]
      @heap[i / 2] = @heap[i]
      @heap[i] = t
      i = i / 2
    end
  end

  def top
    return nil if @size <= 0
    @heap[1]
  end

  def to_a
    return [] if @size == 0
    @heap[1..@size]
  end

  private

  def max_heapify(i)
    l = 2 * i
    r = 2 * i + 1
    largest =
      l <= @size && (@get_key.call(@heap[l]) <=> @get_key.call(@heap[i])) > 0 ? l : i
    largest = r \
      if r <= @size && (@get_key.call(@heap[r]) <=> @get_key.call(@heap[largest])) > 0
    unless largest == i
      t = @heap[i]
      @heap[i] = @heap[largest]
      @heap[largest] = t
      max_heapify(largest)
    end
  end
end


N, M, R = gets.split.map(&:to_i)
rs = gets.split.map { |s| s.to_i - 1 }
edges = M.times.map { gets.split.map(&:to_i) }
graph = Array.new(N) { [] }
edges.each do |(u, v, c)|
  u -= 1
  v -= 1
  graph[u].push([v, c])
  graph[v].push([u, c])
end

def shortest_path(graph, s)
  w_list = Array.new(graph.size, 1 << 60)
  w_list[s] = 0
  queue = PriorityQueue.new
  queue.push([s, 0])
  while !queue.empty?
    v, w = queue.pop
    next if w > w_list[v]
    graph[v].each do |(u, c)|
      if w_list[u] > w_list[v] + c
        w_list[u] = w_list[v] + c
        queue.push([u, w_list[u]])
      end
    end
  end
  w_list
end

ds = {}
rs.each do |r|
  ds[r] = shortest_path(graph, r)
end

def dfs(rs, u, sum_d, ds)
  return sum_d if rs.size == 0
  rs.map do |r|
    trs = rs.dup
    trs.delete(r)
    dfs(trs, r, sum_d + ds[u][r], ds)
  end.min
end

ans = rs.map do |r|
  trs = rs.dup
  trs.delete(r)
  dfs(trs, r, 0, ds)
end.min
puts ans


Measured memory_bytes: 6140
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S;
	in >> S;

	int ans = 114514;
	for (char c = 'a'; c <= 'z'; ++c)
	{
		int cou = 0, res = 0;
		for (auto i : S)
		{
			if (i != c) { ++cou; }
			else
			{
				res = std::max(res, cou);
				cou = 0;
			}
		}
		res = std::max(res, cou);
		ans = std::min(ans, res);
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
s=0
K=int(input())+1
for a in range(1,K):
    for b in range(a,K):
        for c in range(b,K):
            if a==b==c:
                s+=a
                continue
            x=reduce(math.gcd,(a,b,c))
            if a==b or b==c or c==a:
                s+=x*3
            else:
                s+=x*6
print(s)

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

int main(){
     long long n; cin >> n;
     string s; cin >> s;
     char currently = s[0];
     int ane = 1;
     for(int i = 0; i < n; i++){
		 if(s[i] != currently){
			 currently = s[i];
			 ane++;
		 }
	 }   
	 cout << ane << endl;
	   
     return 0;      	     
             
}
	
	


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define acc(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e12+1;
const int mod=1000000007;
//const int mod=998244353;

int n,m,k;
const int N=3e5+10;






int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    int no=31-__builtin_clz(n);
    vector<array<int,3>> adj;
    for(int i=1; i<=no; i++){
        adj.pb({i,i+1,0});
        adj.pb({i,i+1,1<<(i-1)});
    }
    int ans=1<<no;
    for(int i=no-1; i>=0; i--){
        if(n>>i&1){
            adj.pb({i+1,no+1,ans});
            ans+=1<<i;
        }
    }
    cout << no+1 << ' ' << adj.size() << el;
    for(auto it: adj){
        cout << it[0] << ' ' << it[1] << ' ' << it[2] << el;
    }
    return 0;
}






Measured memory_bytes: 3652
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}

// Implements Union-Find Set.
// Manages integers of [0, n).
class UFSet(n: Int) {
  private var ranks = IntArray(n, { 1 })
  private var prevs = IntArray(n, { it })

  // Returns a root of a tree which x belongs to.
  // The argument x needs to be in [0, n).
  fun find(x: Int): Int {
    if (x != prevs[x]) prevs[x] = find(prevs[x])
    return prevs[x]
  }

  // Merges a set which x belongs to and a set which y belongs to.
  // The argument x and y need to be in [0, n).
  fun union(x: Int, y: Int) {
    val xRoot = find(x)
    val yRoot = find(y)
    when {
      ranks[xRoot] > ranks[yRoot] -> prevs[yRoot] = prevs[xRoot]
      ranks[xRoot] < ranks[yRoot] -> prevs[xRoot] = prevs[yRoot]
      prevs[xRoot] != prevs[yRoot] -> {
        prevs[yRoot] = prevs[xRoot]
        ranks[xRoot]++
      }
    }
  }
}

fun main(args: Array<String>) {
  val (n, m) = fastReadInts(2)
  val ps = fastReadInts(n).map { it - 1 }.toIntArray()

  val ufSet = UFSet(n)

  repeat(m) {
    val (xRaw, yRaw) = fastReadInts(2)
    val x = xRaw - 1
    val y = yRaw - 1
    ufSet.union(x, y)
  }

  val groupToIndexes = Array(n, { mutableListOf<Int>() })
  val groupToValues = Array(n, { mutableListOf<Int>() })

  for (i in 0 until n) {
    val group = ufSet.find(ps[i])
    groupToIndexes[group].add(i)
    groupToValues[group].add(ps[i])
  }

  var ans = 0
  for (i in 0 until n) {
    if (groupToIndexes[i].isEmpty()) continue
    val setIndexes = groupToIndexes[i].toSet()
    val setValues = groupToValues[i].toSet()
    val intersection = setIndexes.intersect(setValues)
    ans += intersection.size
  }
  println(ans)
}


Measured memory_bytes: 100668
n = int(input())
if n == 1:
    print(1)
elif 2 <= n <= 3:
    print(2)
elif 4 <= n <= 7:
    print(4)
elif 8 <= n <= 15:
    print(8)
elif 16 <= n <= 31:
    print(16)
elif 32 <= n <= 63:
    print(32)
else:
    print(64)

Measured memory_bytes: 3060
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<int> a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int as, bs;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        b.push_back(temp);
    }
     vector<int> v(n);
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    int j=1;
    do {
        bool check=false;
        for(int i=0;i<n;i++){
            if(v[i]!=a[i]){
                check=true;
            }
        }
        if(!check){
            as=j;
        }
        check=false;
        for(int i=0;i<n;i++){
            if(v[i]!=b[i]){
                check=true;
            }
        }
        if(!check){
            bs=j;
        }
        j++;
    } while( next_permutation(v.begin(), v.end()) );
    cout << abs(as-bs) << "\n";
}



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

int main() {

    ll k,n ;
    string s ;
    cin >>k>> n ;

    vector<ll> a(n) ;
    ll i ;
    for(i=0;i<n;i++) cin >> a[i] ;
    ll ans =INT_MAX ;


    for( i=0;i<n;i++) {
        if (i==0) {
            ans = min(ans,a[n-1]-a[0]) ;
            ans = min(ans,a[0]+k-a[1]) ;
        }
        else if (i==n-1) {
            ans = min(ans,k-a[i]+a[i-1]) ;
            ans = min(ans,a[i]-a[0]) ;
        }
        else {
            ans = min(ans,k-a[i]+a[i-1]) ;
            ans = min(ans,a[i]+k-a[i+1]) ;
        }
    }

    cout << ans << endl ;



}


Measured memory_bytes: 1792
MOD = 1E9+7
N, K = list(map(int, input().split()))
ans = 0
for k in range(K, N+2):
    first = k * (k-1) / 2
    second = k * (2 * N - k + 1) / 2
    add = second - first + 1
    ans = (ans + add) % MOD

print(int(ans))


Measured memory_bytes: 9180
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;


int main(void){

	int ans = 0;
	for( int i = 0; i < 5; i++ ) {
		int n;
		cin >> n;
		if( n < 40 ) ans += 40;
		else ans += n;
	}
	cout << ans / 5 << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
#define int long long

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 2e5 + 5;
const int maxp = 50;


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

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

    int n,m,x;
    cin >> n >> m >> x;
    int a[n][m+1];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            cin >> a[i][j];
        }
    }
    int sol = 999999999;
    for(int i=0;i<(1<<n);i++)
    {
        vector<int>sum(m+1,0);
        for(int j=0;j<n;j++)
        {
            if(i & (1 << j))
            {
                for(int k=0;k<=m;k++)
                {
                    sum[k] += a[j][k];
                }
            }
        }

        bool f = 1;
        for(int k=1;k<=m;k++)
        {
            if(sum[k] < x)
            {
                f = 0;
                break;
            }
        }
        if(f == 1)
        {
            sol = min(sol,sum[0]);
        }
    }
    if(sol == 999999999)
        sol = -1;
    cout << sol;

	return 0;
}



Measured memory_bytes: 3660
import java.util.Scanner;

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

        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) {
                break;
            }

            for (int j = 0; j < w; j++) {
                System.out.print("#");
            }
            System.out.println("");

            for (int i = 0; i < h-2; i++) {
                System.out.print("#");
                for (int j = 0; j < w-2; j++) {
                    System.out.print(".");
                }
                System.out.print("#");
                System.out.println("");
            }

            for (int j = 0; j < w; j++) {
                System.out.print("#");
            }
            System.out.println("");
            System.out.println("");
            
        }
    }
}


Measured memory_bytes: 34340
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x,a,b;
    cin >> x >> a >> b;
    if(b<=a){
      cout << "delicious" << endl;
    }
    else if (x>=(b-a)){
    	cout << "safe" << endl;
    }
    else{
    	cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
const int maxn = 5e5 + 10;
int ans[maxn];
int32_t main(){
    int n,a;
    vector<pii> v;
    cin >> n;
    for (int i =0;i < n;i++){
        cin >> a;
        v.pb({a,i + 1});
    }
    sort(v.rbegin(),v.rend());
    int l = n + 1,sum = 0,lindex= 0;
    for (int i = 0;i < n;i++){
        int num = v[i].F,index = v[i].S;
      //   cout << num << ' ' << sum << ' ' << i  << ' ' <<   lindex << endl;
        if (index < l){
            ans[l] = sum - (num * i);
            sum = num * i;
            lindex = i;
            l = index;
        }
        sum += num;

    }
    ans[l] = sum;
    for (int i = 1;i <= n;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 3568
def main():
    n = int(input())
    v = [int(x) for x in input().split()]
    temp = 0
    v = sorted(v)
    for i in range(n-1):
        if i == 0:
            temp = (v[i]+v[i+1])/2
            continue
        temp = (temp+v[i+1])/2
    print(temp)


if __name__ == '__main__':
    main()


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

int main() {
#ifdef Hwang_Baek_I
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k; cin >> n >> k;
	cout << n - k + 1 << endl;	
	return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC095B
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int N = int.Parse(target[0]);
            int X = int.Parse(target[1]);
            int[] m = new int[N];
            int count = 0;
            int weight = 0;
            for(int i =0; i < N; i++){
                m[i] = int.Parse(Console.ReadLine());
                count++;
                weight += m[i];
            }
            Array.Sort(m);
            while(true){
                if(weight + m[0] <= X) {
                    weight += m[0]; count++;                
                } else break;
            }
            Console.WriteLine(count);
        }
    }
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll x, y, z;
  cin >> x >> y >> z;
  
  x -= z;
  
  cout << x/(y+z) << "\n";

}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(),(x).rend()

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;


int main(){
	int r,d,x;
	cin>>r>>d>>x;

	for (int i = 0; i < 10; ++i){
		cout<<r*x-d<<endl;
		x=r*x-d;
	}


	return 0;
}

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

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  double rad=acos(-1)*(H*30-5.5*M)/180;
  double C=A*A+B*B-2*A*B*cos(rad);
  cout << fixed << setprecision(20) << sqrt(C) << endl;
}

Measured memory_bytes: 4192
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 28;

string table[50];
int h,w;

bool check(vector<char>& c){
	string t[50];
	rep(i,h) t[i]=table[i];
	int n=c.size();
	rep(i,n){
		char cur=c[i];
		int hmin=inf,hmax=-inf;
		int wmin=inf,wmax=-inf;
		rep(j,h)rep(k,w){
			if(t[j][k]==cur){
				hmin=min(hmin,j);
				hmax=max(hmax,j);
				wmin=min(wmin,k);
				wmax=max(wmax,k);
			}
		}

		bool ok=true;
		for(int j=hmin;j<=hmax;j++){
			for(int k=wmin;k<=wmax;k++){
				if(t[j][k]==c[i]||t[j][k]=='*')
					t[j][k]='*';
				else
					ok=false;
			}
		}

		if(!ok)
			return false;
	}
	return true;
}


int main(void){
	int t;
	cin >> t;
	rep(nomeaning,t){
		cin >> h >> w;
		rep(i,h)
			cin >> table[i];
		set<char> tmp;
		rep(i,h)rep(j,w){
			if(table[i][j]!='.')
				tmp.insert(table[i][j]);
		}

		vector<char> c;
		each(it,tmp)
			c.pb(*it);
		sort(c.begin(),c.end());
		bool safe=false;
		do{
			if(safe)
				break;
			safe|=check(c);
		}while(next_permutation(c.begin(),c.end()));

		if(safe||c.size()==0)
			cout << "SAFE" << endl;
		else
			cout << "SUSPICIOUS" << endl;

	}
	return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>

int main(){
  int n,q,S[10000],T[500],i,j,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
	count++;
	break;
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
    int R[MAX], n;
    
    cin >> n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for ( int i = 1; i < n; i++){
        maxv = max(maxv, R[i] -minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 1940
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX] , n;
    
    cin >> n;

    for ( int i = 0; i < n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }   

    cout << maxv << endl;
    
    return 0;
}                                                                                           

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll a;
  cin>>a;
  string S;
  cin>>S;
  if(a>=3200) {
cout<<S<<endl;
  }
else {
cout<<"red"<<endl;
}
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int n,a[100010];
int ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for (int i=0;i<=n-1;i++)
	{if (a[i]==i+1)
	{if (i<n-1 && a[i+1]==i+2)
	swap(a[i],a[i+1]);
	}
	else
	continue;
	ans++;
	}
	cout<<ans<<endl;
	system("pause");
    return 0;
}


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


int main() {
  stack<int> st;
  string s;

  while(cin >> s){
    if ( isdigit(s[0])){
      st.push(atoi(s.c_str()));
    } else {
      int a = st.top(); st.pop();
      int b = st.top(); st.pop();

      if(s == "+") st.push(b + a);
      if(s == "-") st.push(b - a);
      if(s == "*") st.push(b * a);
    }
  }

  cout << st.top() << endl;
  return 0;
}



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

int main() {
    string s;
    cin>>s;
    int a = 0;
    rep(i,s.size()){
        a += s[i] - '0';
    }
    if(stoi(s)%a){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
    
   
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n, i;
	scanf("%d", &n);
	int material[101];
	for (i = 0; i <= n - 1; i++)
	{
		scanf("%d ", &material[i]);
	}
	if (n == 1)
	{
		printf("%d\n", material[0]);
		printf("0\n");
		return 0;
	}
	int j, k, count = 0;
	for (j = 1; j <= n - 1; j++)
	{
		if (material[j]<material[j - 1])
		{
			while ((material[j] >= material[j - 1])==0)
			{
				k = material[j - 1];
				material[j - 1] = material[j];
				material[j] = k;
				count++;
				if (j <= 1) break;
				j-=2;
			}

		}
	}
	int l;
	for (l = 0; l <= n - 2; l++)
	{
		printf("%d ", material[l]);
	}
	printf("%d\n", material[n - 1]);
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 1040
#include<iostream>
#include<vector>
#include<algorithm>
#define INF 10000000000
using namespace std;

vector<long long int> a;
int n;

void maxHeapify(int i){
  int largest;
  int l = i*2;
  int r = i*2+1;

  if(l <= n && a[l] > a[i]) largest = l;
  else largest = i;

  if(r <= n && a[r] > a[largest]) largest = r;

  if(largest != i){
    swap(a[i], a[largest]);
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  for(int i = a.size()/2; i >= 1; i--){
    maxHeapify(i);
  }
}

int main()
{

  cin >> n;

  a.resize(n+5);

  for(int i = 0; i < n+5; i++) a[i] = INF;
  for(int i = 1; i <= n; i++) cin >> a[i];

  buildMaxHeap();

  for(int i = 1; i <= n; i++) cout << " " << a[i];

  cout << endl;

  return 0;

}



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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/
const int inf = 1e9;
vi dp(5000, inf);   // 添え字でbitを持つ。n=12の時bit最大で4095なので5000確保

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    //入力
    int n, m, b; cin >> n >> m;
    vi a(m);
    vi c(m);   //bitで組み合わせを持つ
    rep(i, m) {
        cin >> a[i] >> b;
        rep(j, b) {
            int cc; cin >> cc;
            c[i] = (c[i] | (1<<cc-1));
        }
    }

    //処理
    dp[0] = 0;
    for(int i = 0; i < m; ++i) {
        for(int bit = 0; bit < (1<<n)-1; bit++) {
            chmin(dp[bit | c[i]], dp[bit] + a[i]);
        }
    }

    //出力
    if(dp[(1<<n)-1] == inf) dp[(1<<n)-1] = -1;
    cout << dp[(1<<n)-1] << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
while (1) {
int n, j,k, a[10000], sum = 0, m = 0;
scanf("%d", &n);
if (n == 0)
break;
for (j = 1; j <=n; j++) {
scanf("%d", &a[j]);
sum += a[j];
}
for (j = 1; j <=n; j++) {
if (a[j] <= sum / n)
m++;
}
printf("%d\n", m);
}
return 0;
}



Measured memory_bytes: 2608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char c;
    while(cin>>c){
        if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout<<"vowel"<<endl;
        else cout<<"consonant"<<endl;
    }
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	string s;
	cin >>n;

	cout << n*n <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define N 100010
int main(){
	fast;
	ll n;
	cin>>n;
	ll dp[n+1][3]={0};
	for(int i=1;i<=n;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	return 0;
}/*『你强归你强，Siyuan比你强』*/

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

int main(){
  string s;
  cin>>s;
  string a = s.substr(0,2);
  string b = s.substr(2,4);
  int i = stoi(a);
  int j = stoi(b);

  if(i>12 || i==0){
    if(j>12 || j==0) cout<<"NA\n";
    else cout<<"YYMM\n";
  }else{
    if(j>12 || j==0) cout<<"MMYY\n";
    else cout<<"AMBIGUOUS\n";
  }
  return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int x, n;
    cin >> x >> n;
    vector<int> v(n);
    bool ok = false;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        if(v[i] == x) ok = true;
    }
    if(!ok) {
        cout << x << "\n";
        return 0;
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int id;
    for(int i = 0; i < n; i++) {
        if(v[i] == x) {
            id = i;
            break;
        }
    }
    int xd1 = x + 1;
    for(int i = id + 1; i < n; i++) {
        if(xd1 != v[i]) {
            break;
        }
        xd1++;
    }
    int xd2 = x - 1;
    for(int i = id - 1; i >= 0; i--) {
        if(xd2 != v[i]) {
            break;
        }
        xd2--;
    }
    int ans;
    if(abs(x - xd1) < abs(x - xd2)) ans = xd1;
    else ans = xd2;
    cout << ans << "\n";
    
    return 0;
}


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

using namespace std;

int main(void)
{
    int n, l;
    cin >> n >> l;

    vector<string> s(n);

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

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

   for(int i = 0; i < n; i++)
    cout << s[i]; 

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

/* xxpoxx's definition */
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
using vl = vector<ll>;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    map<string, ll> m;
    REP(i, s.size()){
        m[s.substr(i, 1)]++;
        if(m[s.substr(i,1)] % 2 == 0){
            m[s.substr(i,1)] = 0;
        }
    }
    ll count = 0;
    REP(i, 26){
        if(m[abc.substr(i, 1)] == 1){
            count++;
        }
    }
    if(count == 0){
        cout << 0 << endl;
        return 0;
    }else{
        cout << min(count/2, count-1) << endl;
        return 0;
    }
}


Measured memory_bytes: 3220
local n = io.read("*n")
local x, y = {}, {}
local r = {}
for i = 1, n do x[i], y[i] = io.read("*n", "*n") r[i] = 0 end
local pi2, msi, mco = math.pi * 2, math.sin, math.cos
local mesh = 200000
local mab = math.abs
local dx = pi2 / mesh
local dr = 1 / mesh
for i = 1, mesh do
  local s = msi(dx * i)
  local c = mco(dx * i)
  local maxpos, maxval = 1, c * x[1] + s * y[1]
  for j = 2, n do
    local v = c * x[j] + s * y[j]
    if maxval < v then
      maxpos, maxval = j, v
    end
  end
  r[maxpos] = r[maxpos] + dr
end
for i = 1, n do
  print(string.format("%6f", r[i]))
end


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while(x / y < 1 || x == y) {
        ans++;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

// http://arc081.contest.atcoder.jp/tasks/arc081_b

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n;
  vector<string> a(2);
  cin >> n >> a;

  const int64_t mod = 1000000007;
  int64_t out = 1;
  size_t k = 0; // number of colors adajacent to left!

  for(size_t i = 0; i < n; )
    if(a[0][i] == a[1][i])  // vertical bar
    {
      out = (out * (!k ? 3 : k == 1 ? 2 : 1)) % mod;
      k = 1;
      ++ i;
    }
    else // horizontal
    {
      if (k == 0)
        out = (out * 6) % mod;
      else if (k == 1)
        out = (out * 2) % mod;
      else // k == 2
        out = (out * 3) % mod;

      k = 2;
      i += 2;
    }

  cout << out;
  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int N, W, H;
    cin>> N>> W>> H;
    int x[N], y[N], w[N];
    for(int i=0; i<N; i++) cin>> x[i]>> y[i]>> w[i];

    int r[W+1], s[H+1];
    for(int i=0; i<W+1; i++) r[i]=0;
    for(int i=0; i<H+1; i++) s[i]=0;
    for(int i=0; i<N; i++){
        r[max(0, x[i]-w[i])]++;
        r[min(W, x[i]+w[i])]--;
        s[max(0, y[i]-w[i])]++;
        s[min(H, y[i]+w[i])]--;
    }
    for(int i=0; i<W; i++) r[i+1]+=r[i];
    for(int i=0; i<H; i++) s[i+1]+=s[i];
    bool a=false, b=false;
    for(int i=0; i<W; i++) a|=(r[i]<=0);
    for(int i=0; i<H; i++) b|=(s[i]<=0);

    if(a&&b){
        cout<< "No"<< endl;
    }else{
        cout<< "Yes"<< endl;
    }

    return 0;
}

Measured memory_bytes: 4996
#include <stdio.h>

int main(void)
{
	int a, b, wa, sa, seki;
	
	scanf("%d %d", &a, &b);
	
	wa = a + b;
	sa = a - b;
	seki = a * b;
	
	if(wa >= sa && wa >= seki){
		printf("%d", wa);
	}
	else if(sa >= wa && sa >= seki){
		printf("%d", sa);
	}
	else if(seki >= wa && seki >= sa){
		printf("%d", seki);
	}
	return 0;
}


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

int main()
{
    int a,b,c,d,e,f,g;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    e=a < b ? a : b;
    f=c < d ? c : d;
    g=e+f;
    printf("%d\n",g);
    return 0;
}


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

int main() {
  bool G = false;
  bool W = false;
  bool Y = false;
  bool P = false;
  int N;
  cin >> N;
  for( int i = 0; i < N; i++ ) {
    string H;
    cin >> H;
    if ( H == "G" )
      G = true;
    else if ( H == "W" )
      W = true;
    else if ( H == "Y" )
      Y = true;
    else if ( H == "P" )
      P = true;
    else {
      cout << "error" << endl;
      break;
    }
  }

  if ( G == true &&  W == true && Y == true && P == true ) {
    cout << "Four" << endl;
  } else { cout << "Three" << endl; }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a,b,c;
    sc(a,b,c);
    int wh = min(c,a-b);
    c -= wh;
    cout << c;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include<climits>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
const double pi=acos(-1.0);
#define boost  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define sl(n) scanf("%lld",&n)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define f(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rf(i,a,b) for(ll i = (ll)(a); i > (ll)(b); i--)
#define ms(a,b) memset((a),(b),sizeof(a))
#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define vec(g1) int temp;cin>>temp;g1,push_back(temp);
#define abs(x) ((x<0)?(-(x)):(x))
#define MAX 1000005
#define inf LLONG_MAX
#define MIN INT_MIN
//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
int main(){
	boost;
    int n,l;
    cin>>n>>l;
    int a[n];
    f(i,0,n){a[i]=l+i;}
    sort(a,a+n);
    
    if(a[0]>=0){ ll ans= accumulate(a,a+n,0);
    	        cout<<ans-a[0]<<endl;

    }
    
    else if(a[0]<0){ ll res=MAX;
       f(i,0,n){
       	if(abs(a[i])<abs(res))res=a[i];
       }
        
       ll ans= accumulate(a,a+n,0);
       cout<<ans-res<<endl;
   }
   
   
     	return 0;
    
    
    
}


Measured memory_bytes: 256
n = int(input())

s = []
for i in range(n):
    s.append(input())

result = 0

def judge(board):
    for i in range(n):
        for j in range(i+1, n):
            if board[i][j] != board[j][i]:
                return 0
    return 1

result = 0
for i in range(n):
    board = s[i:] + s[:i]
    result += n * judge(board)

print(result)

Measured memory_bytes: 3064
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();
		
		if (A >= K) {
			System.out.println(A-K + " " + B);
		} else {
			System.out.println(0 + " " + Math.max(0, B-K+A));
		}
	}
}

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


def main():
    from re import compile

    a, b = map(str, input().split())
    s = input()
    pattern = '[0-9]{' + a + '}-{1}[0-9]{' + b + '}'
    re_pattern = compile(pattern)
    result = re_pattern.match(s)

    if result:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){

	int n,pat[8] = { 0,1,2,3,4,5,6,7 }; cin >> n;
	double x[10], y[10];
	for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; };

	double sum = 0; double tori = 0;

	do {
		tori++;
		double way = 0;
		for (int i = 1; i < n; i++) {
			way += sqrt(pow(x[pat[i]] - x[pat[i - 1]],2) + pow(y[pat[i]] - y[pat[i - 1]],2));
		}

		sum += way;
	
	} while (next_permutation(pat,pat + n));
	
	cout << setprecision(18) << sum / tori << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python

import sys
while 1:
  equation = raw_input().split(" ")

  a = int(equation[0])
  b = int(equation[2])
  mark = equation[1]

  if mark == "?":
      sys.exit()
  elif mark == "+":
      print str(a+b)
  elif mark == "-":
      print str(a-b)
  elif mark == "*":
      print str(a*b)
  elif mark == "/":
      print str(a/b)

Measured memory_bytes: 4220
def main():
    n = int(input())
    ans = [0]*(n+1)
    for i in range(1,int(n**0.5+1)):
        for j in range(1,int(n**0.5+1)):
            for k in range(1,int(n**0.5+1)):
                t = i**2+j**2+k**2+i*j+j*k+k*i
                if t<=n:
                    ans[t] += 1
    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9392