akhauriyash/Code-Regression huggingface dataset:
N,K=map(int,input().split())
S=input()
C=[]
flag=False
count=0
prv=S[0]
if S[0]!="1":
    C.append(0)
"""
for i in range(N):
    if prv!=S[i]:
        C.append(count)
        count=1
    else:
        count+=1
    prv=S[i]
if count>0:
    C.append(count)
"""
tmp=0
for i in range(len(S)):
    if i<tmp:
        continue
    j=tmp
    while(S[j]==S[i]):
        j+=1
        if j==len(S):
            break
    C.append(j-i)
    tmp=j
if S[-1]=="0":
    C.append(0)
if len(C)==1:
    print(sum(C))
    exit()
ans=0
#print(C)
sums=[0]*(len(C))
sums.append(0)
for i in range(len(C)):
    sums[i+1]=sums[i]+C[i]
#print(sums)
for left in range(0,len(sums),2):
    right=left+2*K+1
    if right>=len(sums):
        right=int(len(sums))-1
    ans=max(ans,sums[right]-sums[left])
print(ans)

Measured memory_bytes: 47216
n,m = gets.split.map(&:to_i)
ar = gets.split.map(&:to_i)

h = Hash.new(0)

ar.each{|i| h[i] += 1}

m.times do |i|
  a,b = gets.split.map(&:to_i)
  h[b] += a
end

h = h.sort_by{|a,b| -a}.to_h
ans, count = 0,0

#p h

h.each do |a,b|
  break if count >= n
  b.times do
    break if count >= n
    ans += a
    count += 1
  end
end

puts ans


Measured memory_bytes: 41260
#include<stdio.h>
#include<iostream>
using namespace std;

int selectinsert(int A[], int n){
  int i,j,minv;
  int sw=0;
    for ( i = 0;i<n-1;i++){
      minv=i;
      for (j=i;n>j;j++){
        if(A[minv]>A[j]){
        minv=j;
        }
      }
      swap(A[i],A[minv]);
      if(i != minv){
      sw +=1;
      }
  }
  return sw;
}

int main(){
  int n, i, j,sw;
  int A[100];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  sw=selectinsert(A,n);
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);
  return 0;
}

Measured memory_bytes: 3196
main=getLine>>=print.solve.map read.words
solve [n,m]
 | n==1 = m
 | otherwise = go $ (map(div m).reverse)divs++divs
 where
 go (d:divs)
  | d*n<=m = d
  | otherwise = go divs
 divs = f.floor.sqrt.fromIntegral$m
 f 1 = [1]
 f d
  | m`mod`d==0 = d:f(d-1)
  | otherwise = f(d-1)

Measured memory_bytes: 1020
#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...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	string s;
	cin >>n >>s;
	
	rep(i, n-2){
		if(s.substr(i,3)=="ABC") ans++;
	}
	cout << ans <<"\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int s,cnt=1;
    cin >> s;
    while(s!=1 && s!=2 && s!=4){
        if(s%2==0) s/=2;
        else s=s*3+1;
        cnt++;
    }
    cout << cnt+3;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}
map<ll,int> enumpr(ll n) {
	map<ll,int> V;
	for(ll i=2;i*i<=n;i++) while(n%i==0) V[i]++,n/=i;
	if(n>1) V[n]++;
	return V;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

ll A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    auto ep = enumpr(gcd(A, B));
    int ans = ep.size() + 1;
    cout << ans << endl;
}








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

int main() {
	
	int a,b;

	cin >> a >> b;

	if (a > b) {
		cout << a + a - 1 << endl;
	}

	else if(b>a) {
	cout << b + b - 1 << endl;
	}

	else {
		cout << a + b << endl;
	}

}

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

using namespace std;

const int MAX_VALUE = (1 << 31) - 1;

int main() {
	// your code goes here
	//cout << MAX_VALUE << endl;
	int  n, i, j, k;
	cin >> n >> k;
	vector<int> h(n), ans(n, MAX_VALUE);
	for (i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	ans[0] = 0;
	for (i = 0; i < n; i++)
	{
		//cout << ans[i] << " ";
		for (j = 1; j <= k; j++)
		{
			if ((i+j < n) && (ans[i+j] > (ans[i] + abs(h[i] - h[i+j]))))
			{
				ans[i+j] = ans[i] + abs(h[i] - h[i+j]);
			}
		}
		
	}
	cout << ans[n-1];
	return 0;
}

Measured memory_bytes: 1024
ABK=input().split()
A=int(ABK[0]);B=int(ABK[1]);K=int(ABK[2])
list=[]
for i in range(1,min(A,B)+1):
    if (A/i).is_integer() and (B/i).is_integer():
        list.append(i)
list.sort(reverse=True)
print(str(list[K-1]))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 1e5 + 5;
int cnt[N];

void solve() {
    int n, m;
    sc(n, m);
    fr(i, 1, m) {
        int u, v;
        sc(u, v);
        cnt[u]++;
        cnt[v]++;
    }
    fr(i, 1, n) {
        if(cnt[i] & 1) {
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3972
n=input()
s=len(n)
if s%2==0:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2:].count("0")
    r1=s//2-r0
    print(min(l0,r1)*2+min(l1,r0)*2)
if s%2==1:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2+1:].count("0")
    r1=s//2-r0
    tmp=min(l0,r1)*2+min(l1,r0)*2
    if n[s//2]=="0":
        if r1-l0>0 or r0-l1>0:
            tmp+=2
    else:
        if l0-r1>0 or l1-r0>0:
            tmp+=2
    print(tmp)

Measured memory_bytes: 3188
import java.util.*;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char n[] = S.toCharArray();
        
        int sum = 0;
        for( int i = 0; i < S.length(); i++ ) {
            sum += n[i] - 48;
        }
        
        int num = Integer.parseInt(S);
        
        System.out.println( (num % sum == 0) ? "Yes" : "No" );
    }
}


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

char g[10] = {'w','a','k','s','t','n','h','m','y','r'};
char t[5] = {'a','i','u','e','o'};

string change(string key){
  string s = "";
  if(key[0]=='0'&&key[1]=='U') s += "nn";

  else{
    if(g[key[0]-'0']!='a') s += g[key[0]-'0'];
    
    switch(key[1]){
    case 'T':
      s += t[0];
    break;
    case 'L':
      s += t[1];
      break;
    case 'U':
      s += t[2];
      break;
    case 'R':
      s += t[3];
      break;
    case 'D':
      s += t[4];
      break;
    }
  }
  
  return s;
}

int main(){
  string str,ans;

  ans = "";

  cin >> str;
  for(int i = 0 ; i < str.length() ; i++){
    string key = str.substr(i,2);
    if(i%2==0){
     ans += change(key);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

int main() {
  	
  	char S[3];
  	scanf("%s", &S);
  	
  	if(S[1] == 'B'){
  		S[1]='R';
	  }
	  else {
	  	S[1]='B';
	  }
  	
  	printf("%s\n", S);

    return 0;
}


Measured memory_bytes: 3156
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.A
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int a = cin.nextInt();
			int b = cin.nextInt();
			Console.WriteLine(Math.Max(0, a - 2 * b));

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
K, N = map(int, input().split())
A = list(map(int, input().split()))

d = []
for i in range(N-1):
    if A[i+1] - A[i] > K/2:
        d.append(K-A[i+1] + A[i])
    else:
        d.append(A[i+1] - A[i])

if K - A[N-1] + A[0] > K/2:
    d.append(A[N-1] - A[0])
else:
    d.append(K - A[N-1] + A[0])
print(sum(d)-max(d))

Measured memory_bytes: 86220
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    vll a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    vll b;
    ll x=a[0];
    vector<pll> move;
    repf(i,1,n-1){
        if (a[i]<0){b.eb(a[i]);continue;}
        move.eb(mp(x,a[i]));
        x-=a[i];
    }
    move.eb(mp(a[n-1],x));
    x=a[n-1]-x;
    rep(i,b.size()){
        move.eb(mp(x,b[i]));
        x-=b[i];
    }
    cout<<x<<ENDL;
    rep(i,n-1){
        cout<<move[i].F<<" "<<move[i].S<<ENDL;
    }
}


Measured memory_bytes: 5232
#include <iostream>
#include <vector>
#include <deque>
using namespace std;

int main()
{
    string s;
    cin >> s;
    deque<char> deq;
    for (int i = 0; i < s.size(); i++)
    {
        deq.push_back(s[i]);
    }

    int q;
    cin >> q;
    int cursor = 0;
    for (int i = 0; i < q; i++)
    {
        int qq;
        cin >> qq;
        if (qq == 1)
        {
            cursor = 1 - cursor;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if ((cursor == 0 && f == 1) || (cursor == 1 && f == 2))
            {
                deq.push_front(c);
            }
            else
            {
                deq.push_back(c);
            }
        }
    }

    if (cursor == 0)
    {
        for (int i = 0; i < deq.size(); i++)
        {
            cout << deq[i];
        }
        cout << endl;
    }
    else
    {
        for (int i = deq.size() - 1; i >= 0; i--)
        {
            cout << deq[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
 
int main() { 
  int abc , d ;
  cin>> abc ;
  d=0;
  if (abc==111){
   d=3;
  }
  else if (abc==110||abc==101||abc==11){ 
    d=2;
  }
  else if (abc==100||abc==10||abc==1){
    d=1;
  }
  else{
    d=0;
  }
  cout << d << endl;
}

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

using namespace std;

#define int long long

const int   N   = 2e5 + 1;

vector<int> p;
bool npr[N];
int n;
map<int,int> s, f;

void sieve()    {
	for(int i = 2 ; i < N ; ++i)
		if(!npr[i]) {
			p.push_back(i);
			for(int j = i * i ; j < N ; j += i)
				npr[j] = 1;
		}
}

signed main()   {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	sieve();
	
	cin >> n;
	int ans = 0;
	
	for(int i = 1 ; i <= n ; ++i)   {
		int x, y, z;    cin >> x;
		y = z = 1;
		for(int j = 0 ; p[j] * p[j] * p[j] <= x ; ++j) {
			if(x % p[j])    continue;
			int exp = 0;
			while(x % p[j] == 0)    {
				exp = (exp + 1) % 3;
				x /= p[j];
			}
			if(!exp)    continue;
			y *= p[j];
			z *= p[j];
			if(exp < 2) z *= p[j];
			else        y *= p[j];
		}
		if(x > 1)   {
			int t = sqrt(x);
			if(t * t == x)  z *= t, y *= t * t;
			else            y *= x, z *= x * x;
		}
		s[y]++;
		f[y] = z;
	}
	
	if(s.count(1))  {
		ans = 1;
		s.erase(1);
	}
	
	auto it = s.begin();
	while(it != s.end())    {
		int x = it -> first;
		int y = f[x];
		ans += max(s[x],s[y]);
		s.erase(x);
		s.erase(y);
		it = s.lower_bound(x);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 13052
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	m := intScanner()
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		hs[i] = intScanner()
	}
	g := make([]bool, n)
	for i := 0; i < m; i++ {
		a, b := intScanner(), intScanner()
		a--
		b--
		if hs[a] > hs[b] {
			g[b] = true
		} else if hs[a] < hs[b] {
			g[a] = true
		} else {
			g[a] = true
			g[b] = true
		}
	}
	x := 0
	for _, y := range g {
		if !y {
			x++
		}
	}
	fmt.Println(x)
}


Measured memory_bytes: 5520
#include <bits/stdc++.h>
#include <string>
#include <vector>

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

int main() {
    string s_one;
    cin >> s_one;
    // s = num - '0';
    int n = s_one.size(); int ans;
    if (n == 0) ans = 0;

    int start_zero = 0; int start_one = 0;
    string s_zero = s_one;
    rep(i, n) {
        /* code */
        if (s_one[i] != '1' && (i%2) == 0)
        {
            /* code */
            start_one++;
        }
        else if (s_one[i] != '0' && (i%2) == 1)
        {
            /* code */
            start_one++;
        }
    }
    rep(i, n) {
        /* code */
        if (s_zero[i] != '0' && (i%2) == 0)
        {
            /* code */
            start_zero++;
        }
        else if (s_zero[i] != '1' && (i%2) == 1)
        {
            /* code */
            start_zero++;
        }
    }
    cout << ((start_one < start_zero) ? start_one : start_zero) << endl;
}

Measured memory_bytes: 512
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N, K; cin >> N >> K;

    if ((N-1)*(N-2)/2 < K) {
        cout << -1 << endl;
        return 0;
    }

    vvi es(N, vi(N, 0));
    int m = 0;
    FOR(i,1,N){
        es[0][i] = 1;
        es[i][0] = 1;
        m++;
    }

    int k = (N - 1)*(N - 2) / 2;
    bool ok = false;
    for(int i=1; i<N-1; i++) {
        for(int j=i+1;j <N; j++) {
            if (k == K) {
                ok = true;
                break;
            }
            es[i][j] = 1;
            es[j][i] = 1;
            k--;
            m++;
        }
        if (ok) break;
    }

    cout << m << endl;
    REP(i,N-1){
        FOR(j,i+1,N) {
            if (es[i][j] == 1) cout << i+1 << " " << j+1 << endl;
        }
    }

    return 0;
}

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

int main(){
  int f=0,x,ans=0;cin>>x;
  
  while(1){
    f=0;
    for(int i=2;i*i<=x;i++){
      if(!(x%i)){
        f=1;
        break;
      }
    }
    if(f) x++;
    else{
      ans=x;
      break;
    }
  }
  
  cout<<ans;
}

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

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

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N, A[2005];

	cin >> N;
	rep(i,N) cin >> A[i];

	ll sum = 0;
	rep(i,N) sum += A[i];

	bitset<2005*2005> bs;
	bs[0] = true;
	rep(i,N) bs |= bs << A[i];

	ll ans;
	for(ans = (sum+1)/2; ans<=sum; ans++) if( bs[ans] ) break;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1664
from itertools import permutations

A = map(int, raw_input().split())
ans = float('inf')
for p in permutations([0, 1, 2]):
    tmp = abs(A[p[0]] - A[p[1]]) + abs(A[p[1]] - A[p[2]])
    ans = min(ans, tmp)
print ans


Measured memory_bytes: 2568
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]

access = []
for i in 1..N do
  access[i-1] = []
end
for j in 1..M do
  access[lines[j][0]-1].push(lines[j][1])
  access[lines[j][1]-1].push(lines[j][0])
end

label = []
finished = []

for i in 1..N do
  label[i-1] = []
  finished[i-1] = false
end

targets = [1]
while targets.length != 0  do
  current_target = targets[0]
  access[current_target-1].each do |go_from|
    if finished[go_from-1] == false then
      label[go_from-1] = current_target
      targets.push(go_from)
      finished[go_from-1] = true
    end
  end
  targets.delete_at(0)
end

puts "Yes"
for i in 2..N do
  puts label[i-1]
end

Measured memory_bytes: 52436
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[114514];
signed main() {
	int n, k,jj=10000000000,ans;
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	rep(i, n) {
		if (i < n - k+1) {
			if (a[i + k-1] - a[i] < jj) {
				ans = a[i + k-1] - a[i];
				jj = a[i + k-1] - a[i];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,x,brick=1,count=0;
	vector <int> v;
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> x;
		v.push_back(x);
	}
	for(i=0;i<n;i++)
	{
		if(v[i]==brick)
			brick++;
		else
			count++;
	}
	if(count==n)
		cout << "-1\n";
	else
		cout << count << endl;
	return 0;
}

Measured memory_bytes: 1400
def main():
    import sys
    input = sys.stdin.readline
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    A[0] = A[0]%M
    for i in range(1,N):
        A[i] = (A[i] + A[i-1])%M
    
    from collections import defaultdict
    B = defaultdict(int)
    
    for i in A:
        B[i] += 1
    
    ans = 0
    for i in B:
        if i == 0:
            tmp = B[i]*(B[i]+1)//2
            ans += tmp
        else:
            tmp = B[i]*(B[i]-1)//2
            ans += tmp
    
    print(ans)
        
    
    
    
    
    
main()

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int ans = 0;
    int A[N]; rep(i, N) cin >> A[i];
    for(int i = 1; i < N; i++){
        if(A[i] == A[i-1]){
            ans++;
            A[i]+=100;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N);
  REP(i,N) cin >> xs[i];

  VL dpl(21);
  dpl[xs[0]] = 1;
  FOR(j,1,N-1){
	VL tmp(21);
	FOR(k,xs[j],21){
	  tmp[k] += dpl[k-xs[j]];
	}
	FOR(k,xs[j],21){
	  tmp[k-xs[j]] += dpl[k];
	}
	dpl = move(tmp);
  }
  cout << dpl[xs.back()] << endl;

  return 0;
}

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if(0<=x-r&&x+r<=W&&0<=y-r&&y+r<=H)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
from sys import stdin
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))

x = n//1.08
if n==x*1.08//1:
    print(int(x))
elif n==(x+1)*1.08//1:
    print(int(x+1))
elif n==(x-1)*1.08//1:
    print(int(x-1))
else:
    print(":(")


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

int main()
{
int n;double ans=0;scanf("%d",&n);double xi,yi,zi,ri,xj,yj,zj,rj;double x,y,z,r;
vector<tuple<double,double,double,double>> sta(101);vector<vector<double>> dis(101,vector<double>(101,0));vector<bool> check(101,false);
priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> que;
while(n!=0)
{
ans=0;
for(int i=0;i<n;i++)check[i]=false;
for(int i=0;i<n;i++)
{
scanf("%lf %lf %lf %lf",&x,&y,&z,&r);
sta[i]=make_tuple(x,y,z,r);
}
for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)
{
xi=get<0>(sta[i]);yi=get<1>(sta[i]);zi=get<2>(sta[i]);ri=get<3>(sta[i]);xj=get<0>(sta[j]);yj=get<1>(sta[j]);zj=get<2>(sta[j]);rj=get<3>(sta[j]);
dis[i][j]=pow((xi-xj)*(xi-xj)+(yi-yj)*(yi-yj)+(zi-zj)*(zi-zj),0.5)-ri-rj;dis[j][i]=dis[i][j];
}
que.push(make_pair(0,0));
while(!que.empty())
{
pair<double,int> p=que.top();que.pop();
if(check[p.second])continue;
check[p.second]=true;if(p.first>0)ans+=p.first;
for(int i=0;i<n;i++){if(i==p.second)continue;que.push(make_pair(dis[p.second][i],i));}
}
printf("%0.3f\n",ans);
scanf("%d",&n);
}
}


Measured memory_bytes: 3648
import java.util.*;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N= sc.nextInt();
        Integer ans=0;
        Integer[] A= new Integer[N];
        
        
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
        }
        
        Arrays.sort(A, Collections.reverseOrder());
        
        for(int i=0;i<N;i++){
            if(i%2==0){
                ans+=A[i];
            }else{
                ans-=A[i];
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 36220
#include<cstdio>
bool pd(int x) {return (x/10000==x%10)&&((x/1000)%10==(x%100)/10);}
int main()
{
	int l,r,ans=0;scanf("%d%d",&l,&r);
	for(int i=l;i<=r;i++)
	if(pd(i)) ans++;
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
using namespace std;
long long read()
{
	long long x=0,f=1;
	char c=getchar();
	while('0'>c||c>'9'){ if(c=='-') f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
long long minl(long long a,long long b)
{
	return a < b ? a : b;
}
int main()
{
	long long a,b,c;
	a=read(),b=read(),c=read();
	//printf("%lld",a);
	if(a%2==0||b%2==0||c%2==0) 
	{printf("0\n");return 0;}
	printf("%lld",minl(a*b,minl(a*c,b*c)));
}//

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
const int maxn=1e5+5;
ll p[maxn],q[maxn],r[maxn];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	for(int i=1;i<=a;i++)
        cin>>p[i];
    for(int i=1;i<=b;i++)
        cin>>q[i];
    for(int i=1;i<=c;i++)
        cin>>r[i];
	sort(p+1,p+1+a,greater<ll>());
	sort(q+1,q+1+b,greater<ll>());
	sort(r+1,r+1+c,greater<ll>());
	vector<ll>ans;
	for(int i=1;i<=x;i++)
    {
        ans.push_back(p[i]);
    }
    for(int i=1;i<=y;i++)
    {
        ans.push_back(q[i]);
    }
    sort(ans.begin(),ans.end());
    int g=1;
    ll sum=0;
    for(auto &v:ans)
        sum+=v;
    for(auto &v:ans)
    {
        if(r[g]>v)
        {
            sum-=v;
            sum+=r[g];
            g++;
        }
        else
            break;

    }
    cout<<sum<<'\n';








}






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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


VI v[1000];

int main() {


	int n;
	cin >> n;

	bool b = false;
	int m;

	REP(i, 1000) {
		if (i*(i + 1) / 2 == n) {
			b = true;
			m = i + 1;
		}
	}

	if (!b) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	cout << m << endl;

	int cur = 1;
	int cnt = 0;

	FOR(i, 1, m) {
		REP(j, i) {
			v[i].push_back(cur);
			v[cnt].push_back(cur);
			cnt++;
			cur++;
			if (cnt == i)cnt = 0;
		}
	}

	REP(i, m) {
		cout << v[i].size();
		for (int j : v[i]) {
			cout << ' ' << j;
		}
		cout << endl;
	}

}



Measured memory_bytes: 2304
//C - Snuke Festival:  
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int n, j;
ll ans, aux;
map<int, int> maiorA;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    vector<int> a(n), b(n), c(n);
    loop(i, 0, n) cin >> a[i];
    loop(i, 0, n) cin >> b[i];
    loop(i, 0, n) cin >> c[i];
    sort(all(a)); sort(all(b)); sort(all(c));
    j = 0;
    loop(i, 0, n) {
        while(b[i] > a[j] and j < n) {
            j++;
        } 
        maiorA[b[i]] = j;
    }
    j = 0; ans = 0; aux = 0;
    loop(i, 0, n) {
        while(c[i] > b[j] and j < n) {
            aux += maiorA[b[j]];
            j++;
        } 
        ans += aux;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  cout << max(0LL, a - k) << " " << max(0LL, b - max(0LL, k - a)) << endl;
}


Measured memory_bytes: 256
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

l = list(range(1, N + 1))
lst = []

for v in itertools.permutations(l, N):
	lst.append(v)
	
print(abs(lst.index(Q) - lst.index(P)))

Measured memory_bytes: 45040
n, q = map(int, input().split())
s = str(input())
ac = [0] * n
for i in range(1, n):
    ac[i] = ac[i-1]
    if(s[i-1] == "A" and s[i] == "C"):
        ac[i] += 1
for i in range(q):
    l, r = map(int, input().split())
    print(ac[r-1] - ac[l-1])

Measured memory_bytes: 52348
import collections
from operator import mul
from functools import reduce

def C(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
  n = input()
  n = int(n)
  x = []
  for i in range(n):
    l = input()
    x.append(''.join(sorted(l)))

  c = collections.Counter(x)
  values, counts = zip(*c.most_common())
  sum = 0
  for i in range(len(counts)):
    if counts[i] > 1:
      sum += C(counts[i], 2)
  print(sum)


if __name__ == '__main__':
    main()

Measured memory_bytes: 31884
// VALUE THE SACRIFICES..
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define out_of_reach ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
// -----------------------------------------------------------------
void solve()
{
    int n,m;
    cin>>n>>m;
    int ans = n*(n-1)/2 + m*(m-1)/2;
    cout<<ans;
}
signed main()
{
    out_of_reach;
    int t=1;
    //	cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
l = []
M = 10000
h = 1
l.append(h)
while h < M:
    h*=2
    l.append(h)
# print(l)
N,K = map(int,input().split())
ans = 1
res = 0
for i in range(N):
    ans = i + 1
    tmp = 1
    aro = 1
    while ans < K:
        ans *= 2
        tmp = 0.5**aro
        aro += 1
#     print(aro)
    res += tmp
print(res/N)



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

using namespace std;

typedef long long ll;

int main() {
  int n,l;
  cin>>n>>l;
  int sum = 0;
  for (int i = 0; i < n; i++) {
     sum += l + i;
  }
  if (l > 0) sum -= l;
  if (l < 0 && n + l <= 0) sum -= n + l - 1;
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
W, H, x, y = map(int, input().split())

center_x = W/2
center_y = H/2

dx = center_x - x
dy = center_y - y

if dx == 0:
    ans = H*W/2
else:
    slope = dy/dx
    inter = center_y - center_x*slope

    if inter >= 0:
        ay = inter
        by = slope*W + inter
        s_0 = (by + ay)*W/2
        s_1 = H*W - s_0
        ans = min(s_0, s_1)
    else:
        ax = - inter/slope
        bx = (H-inter)/slope
        s_0 = (ax + bx)*H/2
        s_1 = H*W - s_0
        ans = min(s_0, s_1)
print(ans)
if dx == 0 and dy == 0:
    print(1)
else:
    print(0)

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

int main() {
	ll a, b;
	cin >> a >> b;
	if (a == b) {
		cout << a << endl;
		return 0;
	}
	set<ll>ans;
	ll tmp = a;
	while (tmp % 4 != 0 && tmp <= b) {
		ans.insert(tmp);
		tmp++;
	}
	tmp = b;
	while (tmp % 4 != 3 && tmp >= a) {
		ans.insert(tmp);
		tmp--;
	}
	bitset<100> res(0);
	for (auto a : ans) {
		bitset<100> abit(a);
		res = res ^ abit;
	}
	ll bel = 0;
	for (int i = 0; i < 50; i++)bel += res[i] * (ll)pow(2, i);
	cout << bel << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll a,b,c;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>a>>b;
	c=max(0LL,a-b-b);
	cout<<c<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || a % 3 + b % 3 == 3)cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}

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

using namespace std;

long long a[200005], sum, n, N = 1e9 + 7;

int main() {
	cin >> n;
	sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum = (sum + a[i]) % N;
	}
	sum = (sum * sum) % N;
	for (int i = 0; i < n; i++) {
		sum = (sum - a[i] * a[i]) % N;
	}
	sum = (sum + N) % N;
	sum = (sum * 500000004) % N;
	cout << sum;
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n;
	string s;
	ll cnt[5] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'M')cnt[0]++;
		if (s[0] == 'A')cnt[1]++;
		if (s[0] == 'R')cnt[2]++;
		if (s[0] == 'C')cnt[3]++;
		if (s[0] == 'H')cnt[4]++;
	}
	ll ans = 0;
	ans += cnt[0] * cnt[1] * cnt[2];
	ans += cnt[0] * cnt[1] * cnt[3];
	ans += cnt[0] * cnt[1] * cnt[4];
	ans += cnt[0] * cnt[2] * cnt[3];
	ans += cnt[0] * cnt[2] * cnt[4];
	ans += cnt[0] * cnt[3] * cnt[4];
	ans += cnt[1] * cnt[2] * cnt[3];
	ans += cnt[1] * cnt[2] * cnt[4];
	ans += cnt[1] * cnt[3] * cnt[4];
	ans += cnt[2] * cnt[3] * cnt[4];
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long int lint;

int s_to_i(char c)
{
	switch (c) {
	case 'S':
		return 0;
	case 'H':
		return 1;
	case 'C':
		return 2;
	case 'D':
		return 3;
	}
	return -1;
}

char i_to_s(int n)
{
	switch (n) {
	case 0:
		return 'S';
	case 1:
		return 'H';
	case 2:
		return 'C';
	case 3:
		return 'D';
	}
	return 0;
}

void answer()
{
	int n, rank;
	char c;
	bool a[4][16] = { 0 };

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> c >> rank;
		a[s_to_i(c)][rank] = true;
	}
	for (int s = 0; s < 4; s++) {
		for (int i = 1; i <= 13; i++) {
			if (!a[s][i]) cout << i_to_s(s) << " " << i << endl;
		}
	}
}

int main()
{
	answer();
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    rep(i,0,1000){
        a -= d;
        c -= b;
        if(0 < a && 0 < c)continue;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }else if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
    //--------------
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

void dfs(vector<list<ll>> &e,vector<ll> &v,vector<bool> &u,ll n){
    u[n] = true;

    for(auto itr = e[n].begin(); itr != e[n].end(); itr++){
        if(u[*itr])continue;
        v[*itr] += v[n];
        dfs(e,v,u,*itr);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,q;

    cin >> n >> q;

    vector<list<ll>> edge(n+1);
    vector<ll> vertex(n+1,0);

    for(int i = 0; i < n - 1; i++){
        ll a,b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    for(int i = 0; i < q; i++){
        ll a,b;
        cin >> a >> b;

        vertex[a] += b;
    }

    vector<bool> used(n+1,false);

    dfs(edge,vertex,used,1);

    for(int i = 1; i <= n; i++){
        if(i > 1)cout << " ";
        cout << vertex[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 35200
imput = gets.chomp.split(" ")
#puts imput
a = imput[0].to_i
b = imput[1].to_i
c = imput[2].to_i
k = imput[3].to_i
#puts a,b,c,k
if (a >= k) then
    puts k
else
    if (a + b >= k) then
        puts a
    else
        puts (a - (k-a-b))
        #puts k
    end
end
  

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

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

  vector<int> h(n);

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

  int ret = 0;

  while(true){
    int cnt = 0;
    bool ok = false;
    for(int i = 0;i < n;i++){
      if(h[i] != 0){
	ok = true;
	h[i]--;
      }else{
	if(ok)cnt++;
	ok = false;
      }
    }
    if(ok)cnt++;
    ret += cnt;
    if(cnt == 0)break;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
  int n,k;
  cin >> n >> k;
  if(n%k==0){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }
}



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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int h,w,n;cin>>h>>w>>n;
  int res=(n-1)/max(h,w)+1;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int a,b; cin>>a>>b;
    if (a>=13) cout << b << '\n';
    else if (a>=6) cout << b/2 << '\n';
    else cout << 0 << '\n';
    return 0;
}

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

int main(){
  string s;
  cin >> s;

  if(s == "Sunny") cout << "Cloudy";
  if(s == "Cloudy") cout << "Rainy";
  if(s == "Rainy") cout << "Sunny";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,n) for(int i=a;i<n;i++)

int main (){
    int x,n;
    n = 1;
    cin >> x;

    int k,l = 1;

    Rep(i,1,x){
        Rep(j,2,x){
            k = pow(i,j);
            
            if(k > x){
                break;
            }
            
            l = max(k,l);
        }
    }

    cout << l << endl;

    
}

Measured memory_bytes: 256
while True:
    y=[]
    n=int(input())
    if n==0:
        break
    for i in range(1,n+1):
        x=int(input())
        y.append(x)
    for i in range(0,10):
        s=0
        if i in y:
            s=y.count(i)
        if s!=0:
            print("*"*s)
        else:
            print("-")


Measured memory_bytes: 5700
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

struct LowLink {
    const vector<vector<int>> &G;
    vector<bool> used;
    vector<int> ord,low,articulation;
    vector<pair<int, int>> bridge;

    LowLink (const vector<vector<int>> &G) : G(G) {}

    int dfs(int v, int k, int pv) {
        used[v] = true;
        ord[v] = k++;
        low[v] = ord[v];
        bool is_articulation = false;
        int cnt = 0;
        for (auto &nv : G[v]) {
            if (!used[nv]) {
                ++cnt;
                k = dfs(nv, k, v);
                low[v] = min(low[v],low[nv]);
                is_articulation |= ~pv && low[nv] >= ord[v];
                if (ord[v] < low[nv]) bridge.emplace_back(minmax(v, nv));
            } else if (nv != pv) {
                low[v] = min(low[v],ord[nv]);
            }
        }
        is_articulation |= pv == -1 && cnt > 1;
        if (is_articulation) articulation.emplace_back(v);
        return k;
    }

    virtual void build() {
        used.assign(G.size(), false);
        ord.assign(G.size(), 0);
        low.assign(G.size(), 0);
        int k = 0;
        for (int i = 0; i < G.size(); i++) {
            if (!used[i]) k = dfs(i, k, -1);
        }
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M) {
        int a,b; cin >> a >> b;
        --a; --b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    LowLink LL(G);
    LL.build();

    cout << LL.bridge.size() << ln;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
ans=h*w
for x,y in ((h,w),(w,h)):
    x1=x//3
    x2=(x+2)//3
    y2=(y+1)//2
    ans=min(ans,abs(y*x2-y*x1))
    t=(y*x1,y2*(x-x1),(y-y2)*(x-x1))
    ans=min(ans,max(t)-min(t))
    t=(y*x2,y2*(x-x2),(y-y2)*(x-x2))
    ans=min(ans,max(t)-min(t))
print(ans)


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var w string
	fmt.Scan(&w)

	m := map[string]int{}
	for _, c := range w {
		m[string(c)]++
	}

	ans := "Yes"
	for _, cnt := range m {
		if cnt%2 != 0 {
			ans = "No"
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[10], b[10];
    cin >> a >> b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}




Measured memory_bytes: 256