akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int n, x;
	cin >> n >> x;
	vector<int> a(n+1);
	a[0] = 0;
	rep(i, n) {
		int x; cin >> x;
		a[i + 1] = a[i] + x;
	}
	int ans = 0;
	rep(i, n+1) {
		if (a[i] <= x) ans++;
	}
	cout << ans;
	return 0; 
}









Measured memory_bytes: 256
/*
https://atcoder.jp/contests/dp/tasks/dp_h
*/
#include <iostream>
#include <vector>

using namespace std;

const int mod = 1e9 + 7;

template <class T>
void display (const vector <vector <T>> &grid) {
    for (auto &g : grid) {
        for (auto &c : g) {
            cout << c << " ";
        }
        cout << endl;
    }
}

int dfs (const vector <vector <char>> &grid, int row, int col,
         vector <vector <int>> &ways) {
    if (row == grid.size() - 1 && col == grid[0].size() - 1) {
        return 1;
    }
    if (row >= grid.size() || col >= grid[row].size() || grid[row][col] == '#') {
        return 0;
    }

    if (ways[row][col] >= 0) {
        return ways[row][col];
    }
    unsigned long count = 0;
    for (const pair <int, int> &next : initializer_list <pair <int, int>> 
                                            {{row + 1, col}, {row, col + 1}}) {
        int r = next.first, c = next.second;
        count = ((count % mod) + (dfs(grid, r, c, ways) % mod));
    }
    ways[row][col] = count % mod;
    return ways[row][col];
}

// int getNumWays (vector <vector <char>> &grid) {
//     if (grid.empty()) {
//         return 0;
//     }
//     int rows = grid.size(), cols = grid[0].size();
//     vector <vector <int>> ways(rows, vector <int>(cols));
//     return dfs(grid, 0, 0, ways);
// }

int  main () {
    int rows, cols;
    cin >> rows >> cols;
    vector <vector <char>> grid(rows, vector <char>(cols, '.'));

    for (int r = 0; r < rows; ++r) {
        for (int c = 0; c < cols; ++c) {
            char ch;
            cin >> ch;
            grid[r][c] = ch;
        }
    }
    // display(grid);
    vector <vector <int>> ways(rows, vector <int>(cols, -1));
    int result = dfs(grid, 0, 0, ways);
    cout << result << "\n";
    return 0;
}

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

int main(){
    double a,b,c,d=0,e=0;
    string s;
    //2019/04/30
    string ab = "56789";
    string ac = "321";
    cin>>s;
    if(s[5]=='1'){cout<<"TBD"; return 0;}
    if(s[5]=='0'){
        for(int i=0;i<5;i++){
                if(s[6]==ab[i]){cout<<"TBD"; return 0;}
        }
        for(int i=0;i<3;i++){
                if(s[6]==ac[i]){cout<<"Heisei"; return 0;}
        }
        if(s[6]=='4'){
            if(s[8]=='3' && s[9]=='1'){cout<<"TBD"; return 0;}
            else{cout<<"Heisei"; return 0;}
        }
    }
    return 0;
}


Measured memory_bytes: 3560
rr = raw_input
rrm = lambda: map(int, rr().split())

class DSU:
    def __init__(self, N):
        self.par = list(range(N + 1))
        self.rnk = [0] * (N + 1)
        self.sz = [1] * (N + 1)

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x])
        return self.par[x]

    def union(self, x, y):
        xr, yr = self.find(x), self.find(y)
        if xr == yr: return
        if self.rnk[xr] < self.rnk[yr]:
            xr, yr = yr, xr
        if self.rnk[xr] == self.rnk[yr]:
            self.rnk[xr] += 1

        self.par[yr] = xr
        self.sz[xr] += self.sz[yr]

    def size(self, x):
        return self.sz[self.find(x)]
    
def solve(N, A):
    B = {tuple(p):i for i,p in enumerate(A)}
    def solve2(dx, dy):
        dsu = DSU(N)
        for i, (px,py) in enumerate(A):
            nei = (px+dx, py+dy)
            if nei in B:
                dsu.union(i, B[nei])
        return len({dsu.find(i) for i in xrange(N)})
    
    ans = N
    for i, (px,py) in enumerate(A):
        for j, (qx,qy) in enumerate(A):
            if i != j:
                dx = px-qx
                dy = py-qy
                ans = min(ans, solve2(dx,dy))
    return ans

N = int(rr())
A = [rrm() for _ in xrange(N)]
print solve(N, A)


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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr , arr+n);

    long long x=0;
    if(k>=n)
        cout<<'0'<<endl;
    else{
        for(int i=0;i<n-k;i++)
        {
            x+=arr[i];
        }
        cout<<x<<endl;
    }


    return 0;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll r, g, b, K, ans=0, tmp=0;
vector<ll> A;

void dfs(ll rt, ll gt, ll bt, ll ct) {
    if(ct==K) {
        //cout << rt << " " << gt << " " << bt << endl;
        if(gt>rt&&bt>gt) ans++;
        return;
    }
    dfs(2*rt,gt,bt,ct+1);
    dfs(rt,2*gt,bt,ct+1);
    dfs(rt,gt,2*bt,ct+1);
}

signed main(){
    cin >> r >> g >> b >> K;
    dfs(r,g,b,0);
    if(ans==0) cout << "No" << endl; 
    else cout << "Yes" << endl; 
    return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)


int main() {
    ll x=0,y=0,z=0,n,m,ans=0,sum=0,k,w,Max=-1,Min=1e9+1;
    bool ok = true;
    string s,t,u;
    cin >> n >> k;
    ans = 1;
    rep(i,n){
      if(i==0)
        ans *= k;
      else
        ans *= (k-1);
    }
    pri(ans);
    return 0;
}


Measured memory_bytes: 256
module answeroutput
contains
subroutine YNoutput(TF,ch)
  implicit none
  logical,intent(in)::TF
  character,intent(in),optional::ch
  if(present(ch))then
  select case(ch)
    case('Y')
      if(TF)then
        print"(A)","YES"
      else
        print"(A)","NO"
      endif
    case('y')
      if(TF)then
        print"(A)","yes"
      else
        print"(A)","no"
      endif
    case default
      if(TF)then
        print"(A)","Yes"
      else
        print"(A)","No"
      endif
    end select
  else
    if(TF)then
      print"(A)","Yes"
    else
      print"(A)","No"
    endif
  endif
  return
end subroutine
end module
use answeroutput
character(15) S
read*,S
jwin=0
do i=1,len_trim(S)
  if(S(i:i)=="o")jwin=jwin+1
end do
call YNoutput(jwin+15-len_trim(S)>=8,"Y")
end

Measured memory_bytes: 256
class SegmentTreeBase
  def initialize(arr, l = 0, r = arr.size - 1)
    @l, @r = l, r
    if @l == @r
      @agg = arr[l]
    else
      c = (l + r) / 2
      @left_child = self.class.new(arr, l, c)
      @right_child = self.class.new(arr, c + 1, r)
      @agg = aggregation_of(@left_child.agg, @right_child.agg)
    end
  end

  attr_reader :agg, :l, :r

  def update(i, x)
    if @l == @r
      update_single(x)
    else
      (i <= @left_child.r ? @left_child : @right_child).update(i, x)
      @agg = aggregation_of(@left_child.agg, @right_child.agg)
    end
  end

  def query(l, r)
    return @agg if l == @l && r == @r
    return @left_child.query(l, r) if r <= @left_child.r
    return @right_child.query(l, r) if @right_child.l <= l
    agg_left = @left_child.query(l, @left_child.r)
    agg_right = @right_child.query(@right_child.l, r)
    return aggregation_of(agg_left, agg_right)
  end
end

class SegmentTree < SegmentTreeBase
  def aggregation_of(x, y)
    [x, y].min
  end

  def update_single(x)
    @agg = x
  end
end

n, q = gets.split.map(&:to_i)
seg = SegmentTree.new(Array.new(n, 2 ** 31 - 1))
q.times do
  c, x, y = gets.split.map(&:to_i)
  if c == 0
    seg.update(x, y)
  else
    puts seg.query(x, y)
  end
end



Measured memory_bytes: 24836
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define sz(x) (int)(x.size())
#define pb push_back
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define endl "\n"
#define int long long

const int N = (int)(1e6) + 322;
const long long inf = (long long)(1e18) + 123;
const int mod = (int)(1e9) + 7;
const double EPS = 1e-9;

int cnt[111], pw[111];

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    pw[0] = 1;
    for(int i = 1; i <= 60; ++i) {
        pw[i] = pw[i - 1] * 2 % mod;
    }
    for(int i = 1; i <= n; ++i) {
        int x; cin >> x;
        for(int j = 0; j < 61; ++j) {
            if ((x >> j) & 1) cnt[j]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < 61; ++i) {
        int num = (cnt[i]) * (n - cnt[i]) % mod;
        ans = (ans + pw[i] * num % mod) % mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8 = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 },
			{ 1, 1 } };
	static int[][] directions4 = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
	static int ans;
	static int[] data;
	static int[] a;
	static int[] b;
	static int aIdx;
	static int bIdx;
	static int tmpFriends;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		a = new int[n];
		b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);

		ans = 0;
		aIdx = n - 1;
		bIdx = n - 1;
		tmpFriends = 1;
		for (int i = b[n - 1] + 1; i >= 0; i--) {
			while (bIdx >= 0 && b[bIdx] == i) {
				tmpFriends++;
				bIdx--;
			}
			if (i <= n + 1 && tmpFriends >= i) {
				ans = i;
				break;
			}
			while (aIdx >= 0 && a[aIdx] == i) {
				tmpFriends--;
				aIdx--;
			}
		}

		System.out.println(ans - 1);
	}

	// BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for (int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	// //二分探索
	// k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// 二分探索
	// k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}



Measured memory_bytes: 71800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b ,c , d;
  cin >> a >> b >> c >> d;
  a=a+b;
  c=c+d;
  if (a>c)
    cout << "Left" << endl;
  if (a<c)
    cout << "Right" << endl;
  if (a==c)
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
(defun mul (xs &optional (ans 1))
  (cond
    ((null xs) ans)
    ((= ans 0) 0)
    (t (mul (rest xs) (min (+ (expt 10 18) 1) (* ans (first xs)))))))

    
(defun solve (a)
  (if (> a (expt 10 18))
      -1
      a))

(let ((n (read))
      (a (read-from-string
          (concatenate 'string
                       "(" (read-line) ")"))))
     (princ (solve (mul a))))

Measured memory_bytes: 56940
using System;
class aizu{
    public static int Main(){
        int i,n;
        string str;
        for(i=0; ;i++){
        	str = Console.ReadLine();
        	n = int.Parse(str);
        	if(n==0) break;
        	Console.WriteLine("Case {0}: {1}",i+1,n);
        }
        return 0;
    }
}

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
#define rep(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int mod=1e9+7;
vector<int>graph[50];
int32_t main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    vi res(n+1);
    for(int i=1;i<=n;i++){
        res[i]+=graph[i].size();
    }
    rep(i,1,n+1)cout<<res[i]<<endl;

    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a>b)
			System.out.println("a > b");
		else if(a<b)
			System.out.println("a < b");
		else
			System.out.println("a == b");
		sc.close();
	}

}

Measured memory_bytes: 26168
import java.io.PrintWriter
import kotlin.math.abs

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val aList = readLongList()
    val aNumArray = IntArray(100001)
    for (a in aList) {
        aNumArray[a.toInt()]++
    }
    var sum = aList.sum()
    val q = readInteger()
    repeat(q) {
        val (b, c) = readLongList()
        val bNum = aNumArray[b.toInt()]
        aNumArray[b.toInt()] = 0
        aNumArray[c.toInt()] += bNum

        sum += c * bNum - b * bNum
        println(sum)
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 66472
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T> using V = vector<T>;

bool solve() {
    ll N, M;
    cin >> N >> M;

    if(!(N + M)) return false;

    V<V<ll>> prob(M);
    for(ll i = 0; i < N; i++) {
        ll d, v;
        cin >> d >> v;
        prob[d - 1].push_back(v);
    }

    ll ans = 0;
    for(const auto &ele : prob) ans += *max_element(ele.begin(), ele.end());
    cout << ans << endl;
    return true;
}

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



Measured memory_bytes: 3144
#include <stdio.h>

int main(void){

int i, j;
int m[10];

for(i=0; i<10; i++)
scanf("%d", &m[i]);


for(i=0; i<9; i++){

for(j=8; j>=0; j--){

if(m[j]>m[j+1]){

int temp=m[j];
m[j]=m[j+1];
m[j+1]=temp;

           }
     }
}

printf("%d\n", m[9]);
printf("%d\n", m[8]);
printf("%d\n", m[7]);

return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

int main()
{
    IOS;
    int q;
    cin>>q;
    ll a,b,t,sl=0,sr=0,c=0,m;
    multiset<ll> Sl,Sr;
    multiset<ll>::iterator it;
    while(q--)
    {
        cin>>t;
        if(t==1)
        {
            cin>>a>>b;
            c+=b;
            if(Sl.empty())
            {
                sl+=a;
                m=a;
                Sl.insert(a);
            }
            else{
                if((Sl.size()+Sr.size())%2)
                {
                    if(a<m)
                    {
                        sl+=a;
                        Sl.insert(a);
                        sl-=m;
                        sr+=m;
                        Sl.erase(Sl.find(m));
                        Sr.insert(m);
                        it=Sl.end();
                        --it;
                        m=*it;
                    }
                    else{
                        sr+=a;
                        Sr.insert(a);
                    }
                }
                else{
                    if(a>m)
                    {
                        sr+=a;
                        Sr.insert(a);
                        it=Sr.begin();
                        Sr.erase(it);
                        Sl.insert(*it);
                        sr-=*it;
                        sl+=*it;
                        m=*it;
                    }
                    else{
                        sl+=a;
                        Sl.insert(a);
                    }
                }
            }
        }
        else{
            ll nr=Sr.size();
            ll nl=Sl.size();
            //cout<<nl<<" "<<nr<<endl;
            cout<<m<<" "<<(nl-nr)*m-sl+sr+c<<endl;
        }
    }
    return 0;
}


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

int main(){
    string N;
    cin >> N;
    int s=0;
    for(int i = 0; i < (int)N.size(); ++i){
        s+=(int)(N[i] - '0');
    }
    cout << ((s%9==0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3680
#include <stdio.h>
 
int w,h;
char map[20][21];
 
int search(int x,int y) {
    int result=1;
    if(x<0 || x>=w || y<0 || y>=h)return 0;
    if(map[y][x]=='#')return 0;
    map[y][x]='#';
    result+=search(x-1,y);
    result+=search(x+1,y);
    result+=search(x,y-1);
    result+=search(x,y+1);
    return result;
}
 
int main(void) {
    int i,j;
    int sx,sy;
    while(1) {
        scanf("%d%d",&w,&h);
        if(w==0 && h==0)break;
        for(i=0;i<h;i++) {
            scanf("%s",map[i]);
            for(j=0;j<w;j++) {
                if(map[i][j]=='@'){sx=j;sy=i;}
            }
        }
        printf("%d\n",search(sx,sy));
    }
    return 0;
}

Measured memory_bytes: 616
var cube = function(x){return x*x*x;};
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function(line){
  var num_str = line.split(/\n/)[0];
  if(num_str.match(/\d{1,3}/)){
    var num = parseInt(num_str, 10);
    if(num>0){
      if(num<101){
        console.log(cube(num));
      }
    }
  }
});

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

int main(){
  int N,M = 1000001;
  int i,j,ct;
  int w=0,x;

  vector<int> c(M,0);
  cin >> N;
  for(i=0;i<N;i++){
    cin >> x;
    c[x] = 1;
    w = gcd(w,x);
  }

  if (w>1){
    cout << "not coprime" << endl;
    return 0;
  }
  
  for(i=2;i<M;i++){
    ct = 0;
    for(j=i;j<M;j+=i)
      ct += c[j];
    if (ct>1){
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "pairwise coprime" << endl;
  return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

template<unsigned mod>struct mint {
   static int get_mod(){return mod;}
   int val;
   int inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=(ll)val*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=(ll)val*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
using Mint=mint<1000000007>;
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

int main(){
   int n,k; scanf("%d%d",&n,&k);
   vector<int> a(n);
   rep(i,0,n)scanf("%d",&a[i]);
   sort(ALL(a)); Mint ans; factorial fac(101000);
   rep(i,0,n){
      ans+=(fac.nCr(i,k-1)-fac.nCr(n-1-i,k-1))*a[i];
   }
   printf("%d\n",ans.val);
   return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
	    Scanner s = new Scanner(System.in);
	    while(true){
		int[] size = new int[3];
		for(int i=0 ; i<3 ; i++)
		    size[i] = s.nextInt();
		if(size[0]==0)break;
		int num = s.nextInt();
		for(int i=0 ; i<num ; i++){
		    int a = s.nextInt()*2;
		    a*=a;
		    if(a > (size[0]*size[0] + size[1]*size[1]) || a > (size[0]*size[0] + size[2]*size[2]) || a > (size[1]*size[1] + size[2]*size[2]))
			System.out.println("OK");
		    else
			System.out.println("NA");
		}
	    }
	}
}

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

using namespace std;

int main() {
	cin.tie(0);
	cout.tie(0);
	iostream::sync_with_stdio(0);
	int a, b;
	cin>>a>>b;
	if (a < 10 && b < 10)
		cout<<(a*b); else cout<<"-1";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int H,W;
    cin>>H>>W;
    string C[102];
for(int i=0;i<H;i++){
    cin>>C[i];
}
for(int i=0;i<H;i++){
for(int n=0;n<2;n++){
    cout<<C[i]<<endl;
}
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin >> n >> l;
    int sum = 0;
    if(l <= 0 && l + n >= 1)
    {
        for(int i = 0;i < n;i++)
        {
            sum += l + i;
        }
        cout << sum;
    }
    else if(l > 0)
    {
        for(int i = 1;i < n;i++)
        {
            sum += l + i;
        }
        cout << sum;
    }
    else
    {
        for(int i = 0;i < n - 1;i++)
        {
            sum += l + i;
        }
        cout << sum;
    }    

    return 0;
}

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

int main(){
  int n; cin>>n;
  vector<vector<int>> s(n,vector<int>(26,0));

  for(int i=0; i<n; ++i){
    string t; cin>>t;
    for(char x:t)++s[i][x-'a'];
  }

  vector<int> a(26,100);
  for(int i=0; i<26; ++i){
    for(int j=0; j<n; ++j){
      a[i]=min(a[i],s[j][i]);
    }
  }

  for(int i=0; i<26; ++i){
    for(int j=0; j<a[i]; ++j)cout<<char('a'+i);
  }
  cout<<endl;
}


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


int main() {
  while (true) {
    int h, w;
    std::cin >> h >> w;
    if (h == 0 && w == 0) {
      break;
    }
    for (int i = 0; i < h; ++i) {
      for (int k = 0; k < w; ++k) {
        if ((i + k) % 2 == 0) {
          std::cout << "#";
        }else {
          std::cout << ".";
        }

      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <math.h>

#define pi 3.14159265

int main(void)
{
	double a, b, C, S, L, h;

	scanf("%lf %lf %lf", &a, &b, &C);

	S = a * b*sin((C*pi) / 180) / 2;

	L = a + b + sqrt((a*a) + (b*b) - 2 * a*b*cos((C*pi) / 180));

	h = (2 * S) / a;

	printf("%.8f\n", S);

	printf("%.8f\n", L);

	printf("%.8f\n", h);

	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


inline void transpose(vector<string> &a) {

    int n = a.size();
    if (n == 0) return;
    int m = a[0].size();
    vector<string> b(m, string(n, ' '));
    fori (i, n) fori (j, m) b[j][i] = a[i][j];
    a = b;
}


template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#define cerr cout
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}


const int N = 1e5 + 9;

bool dp[N];

void smain() {

    int n, k;
    cin >> n >> k;

    vi a(n);
    fori (i, n) cin >> a[i];
    dp[0] = 0;
    for (int i = 1; i <= k; ++i) {
        for (auto x : a) {
            if (i - x < 0) continue;
            if (dp[i - x] == 0) dp[i] = 1;
        }
    }
    cout << (dp[k] ? "First" : "Second");
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

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

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int n;
int a[N], d[N];
vi g[N];
int c[N];

int dfs(int x, int p = -1) {
    if (g[x].size() == 1) {
        c[x] = 1;
        return a[x];
    }
    ll s = 0, mx = 0;
    for (auto to : g[x])
        if (to != p) {
            ll y = dfs(to, x);
            s += y, mx = max(mx, y);
            c[x] += c[to];
        }
    if (c[x] == 1) {
        if (s != a[x]) {
            cout << "NO\n";
            exit(0);
        }
    }
    else {
        if (s < a[x] || a[x] < s - a[x] || s < 2 * (s - a[x])) {
            cout << "NO\n";
            exit(0);
        }
        if (mx > s - mx && (s - a[x]) > (s - mx)) {
            cout << "NO\n";
            exit(0);
        }
    }
    return a[x] - (s - a[x]);
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    forn(i, 1, n)
        cin >> a[i];
    if (n == 2) {
        cout << (a[1] == a[2] ? "YES\n" : "NO\n");
        return 0;
    }
    forn(i, 1, n - 1) {
        int f, t;
        cin >> f >> t;
        g[f].pb(t);
        g[t].pb(f);
    }
    queue <int> q;
    forn(i, 1, n)
        if (g[i].size() == 1) {
            d[i] = 1;
            q.push(i);
        }
    while (q.size()) {
        int x = q.front();
        q.pop();
        for (auto to : g[x]) {
            if (!d[to]) {
                d[to] = d[x] + 1;
                q.push(to);
            }
        }
    }
    int r = 1;
    forn(i, 2, n)
        if (d[r] < d[i]) r = i;
    cout << (dfs(r) == 0 ? "YES\n" : "NO\n");

    return 0;
}


Measured memory_bytes: 58880
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long a,b,i,d=0;
   double c;
    cin>>a>>b;
     c=(a+b)/2.0;
     d=(a+b)/2;
     if(c==d) cout<<d<<endl;
     else  cout<<"IMPOSSIBLE"<<endl;


  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)

ll fun(ll k,ll v){
	ll ans=0;
while(k%v==0&&k>0)
	ans++,k/=v;
return ans;
}


int main(){



    FAST
//	PRECISE

ll n;
cin>>n;
ve <string> v(n);
FOR(i,0,n)
cin>>v[i];
ve <ve <ll> > z(n,ve <ll>(3));
FOR(i,0,n){
	ll mul=0;
	ll num=0;
	FOR(j,0,v[i].size()){
		if(v[i][j]=='.')z[i][0]=(v[i].size()-j-1);
		else{
			num=num*10+(v[i][j]-'0');
		}
	}
	z[i][1]=fun(num,2);
	z[i][2]=fun(num,5);
	//cout<<z[i][0]<<endl;
}
ve <pair<ll,ll>> v1(n);
const ll maxn=100;
map <ll,map <ll,ll>> m;
FOR(i,0,n){
v1[i]={z[i][1]-z[i][0],z[i][2]-z[i][0]};
//cout<<v1[i].F<<" "<<v1[i].S<<endl;
m[v1[i].F][v1[i].S]++;
}
FORR(i,100,-100){
	FORR(j,100,-100)
	m[i][j]+=m[i+1][j]+m[i][j+1]-m[i+1][j+1];
}
ll ans=0;
//cout<<m[-2][1]<<endl;
FOR(i,0,n){
	ll x1=-v1[i].F;
	ll x2=-v1[i].S;
	ans+=m[x1][x2];
	if(min(v1[i].F,v1[i].S)>=0)ans--;
	//cout<<ans<<endl;
}

ans/=2;
cout<<ans;


return 0;
 }
 


Measured memory_bytes: 26136
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int need1 = 0, need2= 0;
  int cnt = 0;
  for(int i=0;i<s.size();i++) {
    if(s[i] == '(') {
      cnt++;
    } else {
      if(cnt == 0) {
        need1++;
      } else {
        cnt--;
      }
    }
  }

  string ans = "";
  for(int i=0;i<need1;i++) {
    ans += '(';
  }
  ans += s;
  for(int i=0;i<cnt;i++) {
    ans += ')';
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  string s;
  cin>>s;
  if(n<3200)
  {
    cout<<"red"<<endl;
  }else
  {
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk;
  lll n;
  vector<lll> a,b,c;
  cin >> n;
  a.resize(n);
  b.resize(n);
  c.resize(n-1);

  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  
  for(ii=0;ii<n;ii++){
    cin >> b[ii];
  }
  for(ii=0;ii<n-1;ii++){
    cin >> c[ii];
  }
  lll sum = 0;
  lll prev;
  prev = -100;

  for(ii=0;ii<n;ii++){
    sum+=b[a[ii]-1];
    
    if(prev + 1 == a[ii]){
      sum += c[prev-1];
    }
    
    prev = a[ii];

  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]
d={}
for i in range(n):
  if a[i] in d:
    d[a[i]]+=1
  else:
    d[a[i]]=1
cnt=0
d=list(d.items())
for i in range(len(d)):
  if d[i][1]%2==1:
    cnt+=1
print(cnt)

Measured memory_bytes: 20232
n = int(input())
ans = []
for i in range(1,n+1):
    if i%3 == 0:
        ans.append(i)
        continue
    tmp = i
    while tmp != 0:
        if tmp % 10 == 3:
            ans.append(i)
            flg = True
            break
        else:
            tmp //= 10
        

print(" " + " ".join([str(s) for s in ans]))


Measured memory_bytes: 6120
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
    ll n,i,sum=0,count=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    
    for(i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            count = a[i-1] - a[i];
            a[i]=a[i]+count;
            sum= sum+count;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 5180
#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;
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; }

int H,W,K;
vector<string>fi;

//status unsolved
int solve(){
    
    int res=1<<29;
    for(int bit=0;bit<(1<<(H-1));++bit){
        bool gok=true;//そもそも不可能な場合もあるのでその判定
        int N=0;
        vector<int>ord(H,0);

        for(int i=0;i<H-1;++i){
            //横に切る分割
            if(!(bit&(1<<i)))ord[i+1]=ord[i];
            else ord[i+1]=ord[i]+1,++N;
        }
        //縦に切った回数
        int add=0;
        //横に切ったケーキのそれぞれに載っているチョコの数
        vector<int>nums(N+1,0);

        for(int w=0;w<W;++w){
            //その1列のミルクチョコの数を記録
            vector<int>one(N+1,0);
            bool ok=true;

            for(int h=0;h<H;++h){
                one[ord[h]]+=fi[h][w]-'0';
                nums[ord[h]]+=fi[h][w]-'0';
                //1列に中でKより多ければそもそも不可能
                if(one[ord[h]]>K)gok=false;
                //2列目以降でKより多ければ切る
                if(nums[ord[h]]>K)ok=false;
            }
            //K個より多ければ縦に切る
            if(!ok)++add,nums=one;
        }
        if(gok)chmin(res,N+add);
    }


    return res;

}

int main(){
    cin >>H>>W>>K;
    fi.resize(H);
    for(int i=0;i<H;++i)cin>>fi[i];
    cout<<solve()<<endl;
}
/*


*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<vector<int> > Graph;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l),S.substr(l, r)
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//'0'+cnt 数字cntからcharへの変換

int main(){

    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
//テンプレート
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
    int N,Q,i,j,strCount=0,powCount=0,ans=0;
    
    //入力開始
    scanf("%d%d",&N,&Q);
    int l[Q],r[Q];
    char S[N];
    int T[N];
    scanf("%s",S);
    
    T[0]=0;
    //ACの並びのAをaに置き換える
    for (i=0; S[i]!='\0'; i++) {
        if (S[i]=='C'&&S[i-1]=='A') { //累積和の数列を作っておく
            T[i]=T[i-1]+1;
        }else{
            T[i]=T[i-1];
        }
    }
    
    for (i=0; i<Q; i++) {
        scanf("%d%d",&l[i],&r[i]);
    }
    //入力完了
    
    //ここから処理
    for (i=0; i<Q; i++) {
        ans=T[r[i]-1]-T[l[i]-1];
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

// 19
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n + 1];
        for(int i = 0; i < m; i++)
            a[sc.nextInt()] = 1;

        int left = 0;
        int right = 0;
        for(int i = 0; i < x; i++)
            left += a[i];
        for(int i = x; i < n + 1; i++)
            right += a[i];

        System.out.println(Math.min(left, right));
    }

}


Measured memory_bytes: 35880
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class DisjointSet {
		
		int[] p;
		int[] rank;

		public DisjointSet(int size) {
			p = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) makeSet(i);
		}

		private void makeSet(int x) {
			p[x] = x;
			rank[x] = 0;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}

		private int findSet(int x) {
			int v = x;
			int parent = p[v];
			while (parent != v) {
				parent = p[v];
				v = p[parent];
				p[x] = parent;
			}
			return parent;
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] < rank[y]) {
				p[y] = x;
			} else {
				p[x] = y;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}	
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//		BufferedReader reader = new BufferedReader(new FileReader("D:\\temp\\20190422\\in.txt"));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int m = Integer.parseInt(st.nextToken());
		for (int i = 0; i < m; i++) {
			st = new StringTokenizer(reader.readLine());
			int id1 = Integer.parseInt(st.nextToken());
			int id2 = Integer.parseInt(st.nextToken());
			ds.unite(id1, id2);
		}
		
		int q = Integer.parseInt(reader.readLine());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int id1 = Integer.parseInt(st.nextToken());
			int id2 = Integer.parseInt(st.nextToken());
			if (ds.same(id1, id2)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}
}


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


ll mod = 1e9 + 7;
const int N = 21;
int dp[N][1 << N];
int arr[N][N];
int n;

void add_self(int &a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
}

int solve(int idx, int msk) {
    if (idx == n)
        return 1;
    if (dp[idx][msk] != -1)
        return dp[idx][msk];
    int res = 0;
    for (int j = 0; j < n; j++)
        if (arr[idx][j] && !((1 << j) & msk))
            add_self(res, solve(idx + 1, msk | (1 << j)));
    return dp[idx][msk] = res;
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> arr[i][j];
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 172288
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int H, W;
	int c[10][10];
	int n[10] = {};
	cin >> H >> W;

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}

	for (int x = 0; x < W; x++) {
		for (int y = 0; y < H; y++) {
			int A;
			cin >> A;
			if (A >= 0) n[A]++;
		}
	}

	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (c[i][j] > c[i][k] + c[k][j])
					c[i][j] = c[i][k] + c[k][j];
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 10; i++) {
		ans += c[i][1] * n[i];
	}

	cout << ans << endl;
}


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

#define fi first
#define se second

const int N = 100100;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int a[N];
long long k;

int main()
{
        ios_base::sync_with_stdio(0);

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

        cin >> n >> k;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
        }
        long long res = 0, A = 0;
        for(int i = 1; i <= n; i++){
                long long B = 0;
                for(int j = i + 1; j <= n; j++){
                        A += (a[i] > a[j]);
                }
                for(int j = 1; j <= n; j++){
                        B += (a[i] > a[j]);
                }
                res = (res + B * (k * (k - 1) / 2 % mod)) % mod;
        }
        cout << (res + A * k) % mod << "\n";
}


Measured memory_bytes: 256