akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    char x='z';
    while(true){
        if(x=='z'||x=='a'){
            if(a==""){
                cout << 'A' << endl;
                return 0;
            }
            x = a[0];
            a = a.substr(1);
            continue;
        }
        if(x=='b'){
            if(b==""){
                cout << 'B' << endl;
                return 0;
            }
            x = b[0];
            b = b.substr(1);
            continue;
        }
        if(x=='c'){
            if(c==""){
                cout << 'C' << endl;
                return 0;
            }
            x = c[0];
            c = c.substr(1);
            continue;
        }
    }
    if(a=="")cout << 'A' << endl;
    if(b=="")cout << 'B' << endl;
    if(c=="")cout << 'C' << endl;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  vector<pair<string, ll>> v(N);
  rep(i, N) { cin >> v[i].first >> v[i].second; }
  string s;
  cin >> s;
  ll i = 0;
  while (v[i].first != s)
    i++;
  i++;
  ll ans = 0;
  while (i < N) {
    ans += v[i].second;
    i++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
int main() {
	long long n, z, w;
	cin >> n >> z >> w;
	vector<long long> wow;
	REP(i, n) {
		long long tmp;
		cin >> tmp;
		wow.push_back(tmp);
	}
	if (n == 1) {
		cout << abs(w - wow[0]) << endl;
		return 0;
	}
	long long ans = abs(w - wow[n - 1]);
	ans = max(ans, abs(wow[n - 1] - wow[n - 2]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	as := make([]int, N)
	for i := 0; i < N; i++ {
		as[i] = nextInt()
	}
	colorSelected := make([]bool, 8)
	var hackerCnt int
	for _, a := range as {
		colorType := a / 400
		if colorType < 8 {
			colorSelected[colorType] = true
		} else {
			hackerCnt++
		}
	}
	var colorCnt int
	for _, isSelect := range colorSelected {
		if isSelect {
			colorCnt++
		}
	}
	minCnt := colorCnt
	if colorCnt == 0 && hackerCnt > 0 {
		minCnt = 1
	}
	fmt.Printf("%d %d\n", minCnt, colorCnt+hackerCnt)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <algorithm>
#include <iterator>
#include <iostream>
//#include <iomanip>
//#include <cstring>
//#include <cstdlib>
#include <string>
#include <vector>
//#include <queue>
//#include <cmath>
//#include <set>
#include <map>
using namespace std;
#ifdef LOCAL
#define DEBUGMSG()                                                              \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]" ;        \
}
#define DEBUGVAR(x)                                                             \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    cerr << "([" << typeid(x).name() << "]" << #x << ")" << x << endl ;         \
}
#define DEBUGARR(l, r)                                                          \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    copy(l, r, ostream_iterator<decltype(*l)>(cerr, " "));                      \
    cerr << endl ;                                                              \
}
#else
#define DEBUGMSG()
#define DEBUGVAR(x)
#define DEBUGARR(l, r)
#endif // LOCAL

typedef long long i64;
int H, W, N;
i64 empt, ans[11];
map <pair<int, int>, int> mp;

int main()
{
    int u, v;
    cin >> H >> W >> N ;
    empt = 1LL * (H - 2) * (W - 2);
    while(N--)
    {
        cin >> u >> v ;
        for(int i = -1; i <= 1; i++)
        {
            for(int j = -1; j <= 1; j++)
            {
                if(u + i < 1 || u + i > H)
                    continue;
                if(v + j < 1 || v + j > W)
                    continue;
                mp[make_pair(u+i, v+j)]++;
            }
        }
    }

    for(auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        if(itr->first.first <= 1 || itr->first.first >= H)
            continue;
        if(itr->first.second <= 1 || itr->first.second >= W)
            continue;
        cerr << itr->first.first << " " << itr->first.second << " " << itr->second << endl ;
        ans[itr->second]++;
        empt--;
    }

    cout << empt << endl ;
    for(int i = 1; i <= 9; i++)
        cout << ans[i] << endl ;

}



Measured memory_bytes: 58496
(defun isEasy (n c)
  (or 
   (and (evenp n) (not (string= c #\R)))
   (and (oddp n) (not (string= c #\L)))
   )
  )
(defun notEasyList (str) 
 (loop
  with x = 0
  for c across str
  when (not (isEasy (incf x) c))
  collect x
 )
)
(defun isEasyTapDance (str)
  (if (null (notEasyList str))
      "Yes"
      "No"
  )
)
(princ (isEasyTapDance (string (read))))

Measured memory_bytes: 6504
N = int(input())
T = [int(t) for t in input().split()]
A = [int(a) for a in input().split()]

mod = 10**9+7
TM = [0]*N
TM[0] = T[0]
AM = [0]*N
AM[-1] = A[-1]
for i in range(N-1):
    if T[i] < T[i+1]:
        TM[i+1] = T[i+1]
    if A[i+1] < A[i]:
        AM[i] = A[i]

M = [0]*N
ans = 1
for i in range(N):
    if TM[i] > 0 and AM[i] > 0 and TM[i] != AM[i]:
        ans = 0
    elif TM[i] > 0 and AM[i] == 0 and TM[i] <= A[i]:
        M[i] = TM[i]
    elif TM[i] == 0 and AM[i] > 0 and AM[i] <= T[i]:
        M[i] = AM[i]
    elif TM[i] == AM[i]:
        M[i] = TM[i]
    elif TM[i] == 0 and AM[i] == 0:
        continue
    else:
        ans = 0
        break

for i in range(N):
    if M[i] > 0:
        continue
    ans *= min(T[i], A[i])
    ans %= mod

print(ans)

Measured memory_bytes: 18712
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int N, M;
int main(){
	cin >> N >> M;
	int l, r;
	cin >> l >> r;
	for(int i=1; i<M; i++){
		int a, b;
		cin >> a >> b;
		l = max(l, a);
		r = min(r, b);
	}
	cout << max(0,r-l+1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  ll len = S.size();
  vector<char> arr;
  map<char, ll> amap;
  for(ll i=0;i<len;++i) {
    if(amap[S[i]]==0) arr.push_back(S[i]);
    amap[S[i]]++;
  }
  ll ans = len*(len-1)/2;
  for(ll i=0;i<arr.size();++i) {
    ans -= amap[arr[i]]*(amap[arr[i]]-1)/2;
  }
  cout<<ans+1<<endl;
}



Measured memory_bytes: 3768
#include<stdio.h>

int main(){
	int n,m;
	int x,y,a,b;
	int board[21][21];
	int i,j;
	char c;
	int f;

	while(scanf("%d",&n),n){
		x = 10;
		y = 10;
		f = 0;
		
		for(i = 0;i < 21;i++){
			for(j = 0;j < 21;j++){
				board[i][j] = 0;
			}
		}
		
		for(i = 0;i < n;i++){
			scanf("%d%d",&a,&b);
			board[a][b] = 1;
		}

		scanf("%d",&m);
		for(i = 0;i < m;i++){
			scanf("%s %d",&c,&a);
			for(j = 0;j < a;j++){
				if(c == 'E')x++;
				else if(c == 'S')y--;
				else if(c == 'W')x--;
				else if(c == 'N')y++;
				if(board[x][y] == 1)board[x][y] = 0;
			}
		}

		for(i = 0;i < 21;i++){
			for(j = 0;j < 21;j++){
				if(board[i][j] == 1)f = 1;
			}
		}
		if(f == 1)puts("No");
		else puts("Yes");
	}
	return 0;
}

				

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

int main() {
  char c;
  cin >> c;
  const char* result = "consonant";
  if ((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u')) {
    result = "vowel";
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,z,i,max;

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

  if(x==y) max=x; //二つの数が等しいとき、最大公約数はｘ、ｙ

  else if(x>=y){   //ユークリッド互除法
    while(y>0){    //ｘ＝ｙｎ＋ｘ％ｙ（＝ｙ）
      z=x%y;       //
      x=y;         //
      y=z;
    }
    max=x;
  }
  else{
    while(x>0){
      z=y%x;
      y=x;
      x=z;
    }
    max=y;
  }
  printf("%d\n",max);


  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF 1e15
ll Q;
ll f, x,xa,bb,al,ah;
ll i, j, k,l;
vector<ll> anss;
priority_queue<ll,vector<ll>,greater<ll>> aqh;
priority_queue<ll> aql;

int main(){
    scanf("%lld", &Q);
    j = 0;
    f = 0;
    x = 0;
    aql.push(-INF);
    aqh.push(INF);
    fornum(i,0,Q){
        ll q;
        scanf("%lld", &q);
        if(q==1){
            ll a, b;
            scanf("%lld%lld", &a, &b);
            bb += b;
            if(aql.size()==aqh.size()){
                ll qa = aqh.top();
                if(qa<a){
                    aqh.pop();
                    aqh.push(a);
                    aql.push(qa);
                    ah -= qa - x;
                    al += x - qa;
                    ah += a - x;
                }else{
                    aql.push(a);
                    al += x - a;
                }
            }else{
                ll qa = aql.top();
                if(a<qa){
                    aql.pop();
                    aql.push(a);
                    aqh.push(qa);
                    al -= x - qa;
                    ah += qa - x;
                    al += x - a;
                }else{
                    aqh.push(a);
                    ah += a-x;
                }
            }
            ll nx = aql.top();
            al += (aql.size() - 1) * (nx - x);
            ah -= (aqh.size() - 1) * (nx - x);
            x = nx;
            j++;
        }else{
            if(j!=0)
            printf("%lld %lld\n", x, al + ah + bb);
        }
        //printf("b%lld %lld\n", aql.top(), aqh.top());
    }
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
char s[100009];
long long n,i,ans,f[29];
int main()
{
    for(scanf("%lld%s",&n,s); s[i]; ++f[s[i++]-'a']);
    for(ans=1,i=29; i--; ans=ans*(1+f[i])%1000000007);
    printf("%lld\n",(ans+1000000006)%1000000007),exit(0);
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> l(Q), r(Q);
  REP(i, Q)
  {
    cin >> l[i] >> r[i];
    l[i]--, r[i]--;
  }
  vector<int> count(N);
  count[0] = 0;
  REP1(i, N - 1)
  {
    count[i] = count[i - 1];
    if (S[i - 1] == 'A' && S[i] == 'C')
      count[i]++;
  }
  REP(i, Q)
  cout << count[r[i]] - count[l[i]] << endl;
  return 0;
}

Measured memory_bytes: 2176
def b81_re(N):
    if N>81:
        return 'No'
    for i in reversed(range(1,10)):
        if N%i == 0:
            if N/i<=9:
                return 'Yes'
    return 'No'


if __name__ == "__main__":
    N = int(input())
    print(b81_re(N))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC68();
}

void ABC68(void){
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

ll a[101], p[101];

ll f(int n, ll x) {
	if (n == 0) {
		if (x == 0)
			return 0;
		else
			return 1;
	}

	if (x == 0)
		return 0;

	if (x <= 1 + a[n - 1])
		return f(n - 1, x - 1);
	else
		return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);

}

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

	int n;
	ll x;
	cin >> n >> x;

	a[0] = p[0] = 1;
	rep (i, 1, n) {
		a[i] = 2 * a[i - 1] + 3;
		p[i] = 2 * p[i - 1] + 1;
	}

	cout << f(n, x) << endl;

	return 0;
}


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

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    if (a >= (n + b - 1) / b && a + b <= n + 1) {
        vector<int> g, sol;
        g.push_back(b);
        int res = n - b, cur_a = 1;
        while (res > 0) {
            if (res >= b && res - b >= a - cur_a - 1) {
                res -= b;
                g.push_back(b);
                cur_a++;
            } else if (a - cur_a > 1) {
                res--;
                g.push_back(1);
                cur_a++;
            } else {
                g.push_back(res);
                res = 0;
                cur_a++;
            }
        }
        int cur = 0;
        for (int i = 0; i < g.size(); i++) {
            int max = cur + g[i];
            for (int j = max; j > cur; j--) {
                sol.push_back(j);
            }
            cur = max;
        }
        for (int i = 0; i < n; i++) {
            if (i) printf(" ");
            printf("%d", sol[i]);
        }
        puts("");
    } else {
        puts("-1");
    }
    return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define int long long
using namespace std;
signed main() {
	int n, l; cin >> n >> l;
	int ans = 0, p = l + 1 - 1;
	for (int i = 2; i <= n; i++) {
		if (abs(l + i - 1) < abs(p)) {
			ans += p; p = l + i - 1;
		}
		else ans += l + i - 1;
	}
	cout << ans << endl;
	cin >> n;
  }

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))
s = A.sum()
l = -1
r = 10**12
while l+1 < r:
    m = (l+r) // 2 
    # 全てのA、Fにつき、Aとm//Fで小さい方の合計がK以下
    # m//Fは修行したあとの消化コスト
    if s - np.minimum(A, m//F).sum() <= K:
      r = m
    else:
      l = m
print(r)

Measured memory_bytes: 38596
// B - Small and Large Integers
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int A,B,K; cin>>A>>B>>K;
	int n = B-A+1;
	if(n < 2*K) rpz(i, n) cout<< A+i <<endl;
	else{
		rpz(i, K) cout<< A+i <<endl;
		rp(i, n-K, n) cout<< A+i <<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main(){
  int N , X ;
  cin >> N >> X ;
  int place = 0;
  int A[N];
  rep(i,N) cin >> A[i] ;
  int counter = 1 ;
  rep(i,N){
    place += A[i];
    if( place <= X ) counter++ ;
    else break ;
}
  cout << counter << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> ans(N+1);
  for(int i=2; i<=N; i++) {
    int a; cin >> a;
    ans[a]++;
  }

  for(int i=1; i<=N; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 4056
#include <iostream>

using namespace std;

using ll = long long;

int main() {
    ll N;
    cin >> N;

    ll A[N], sum = 0;
    for (ll i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }

    if (sum % (N * (N + 1) / 2) > 0) {
        cout << "NO" << endl;
        return 0;
    }

    // 合計操作回数
    ll M = sum / (N * (N + 1) / 2);

    for (ll i = 0; i < N; ++i) {
        ll d = A[(i + 1) % N] - A[i];

        // 箱iの選ばれる回数は(M-d)/Nとなる
        // この値は非負整数でなくてはならない
        if (M < d || (M - d) % N > 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int a, b;
    cin >> a >> b;
    if ((a+b)%2==0)cout << (a+b)/2 << endl;
    else cout << (a+b)/2+1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {

  loop
  @tailrec
  def loop: Unit = {
    val max = readInt
    if (max == 0) return
    val n = readInt
    val cell = 0 +: Array.tabulate(n){i ⇒
      val d = readInt
      if (d + i + 1 > n + 1) n + 1
      else if (d + i + 1 < 0) 0
      else d + i + 1
    } :+ n + 1
    val canReachFrom = Array.tabulate(n + 2){_ ⇒ Nil: List[Int]}
    val canStop = Array.tabulate(n + 2){_ ⇒ false}
    canStop(0) = true
    val queue = mutable.Queue[Int](0)
    while(queue.nonEmpty){
      val current = queue.dequeue()
      for (i ← current + 1 to math.min(n + 1, current + max)){
        canReachFrom(cell(i)) ::= current
        if (!canStop(cell(i))) {
          canStop(cell(i)) = true
          queue.enqueue(cell(i))
        }
      }
    }
    for (i ← canStop.indices) canStop(i) = false
    canStop(n + 1) = true
    queue.enqueue(n + 1)
    while (queue.nonEmpty){
      val current = queue.dequeue()
      for (i ← canReachFrom(current) if !canStop(i)) {
        canStop(i) = true
        queue.enqueue(i)
      }
    }
    println(
      if (canStop.indices.forall(i ⇒ canStop(i) || canReachFrom(i).isEmpty)) "OK" else "NG"
    )
    loop
  }
}



Measured memory_bytes: 60460
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		var dic = new Dictionary<string, int>();
		for (int i = 0; i < N; i++)
		{
			var item = Console.ReadLine();
			if (dic.ContainsKey(item))
			{
				dic[item]++;
			}
			else
			{
				dic[item] = 1;
			}
		}
		int M = int.Parse(Console.ReadLine());
		for (int i = 0; i < M; i++)
		{
			var item = Console.ReadLine();
			if (dic.ContainsKey(item))
			{
				dic[item]--;
			}
			else
			{
				dic[item] = -1;
			}
		}
		int max = int.MinValue;
		foreach (var item in dic)
		{
			max = Math.Max(max, item.Value);
		}
		Console.WriteLine(Math.Max(0, max));
	}
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main() {
	int S = 0, ans = 0, base = 1;
	int sum[ 2025 ] = {};
	string s; cin >> s;
	int N = s.size(), P = 2019;

	sum[ 0 ] = 1;
	for(int i = N-1; i >= 0; --i){
		S = ( S + ( s[ i ] - '0' ) * base ) % P;
		ans += sum[ S ]++, base = base * 10 % P;
	}
	cout << ans << endl;
}

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;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


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

using namespace std;

using ll = long long;

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

int main() {
  int n;
  cin >> n;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum += x;
    freq[x]++;
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    sum -= (ll) a * freq[a];
    //cout << "hi " << sum << ' ' << freq[a] << '\n';
    int x = freq[a];
    freq[a] = 0;
    freq[b] += x;
    sum += (ll) b * x;
    cout << sum << '\n';
  }
  return 0;
}


Measured memory_bytes: 3980
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll K,N;
ll ans;
string S;
vector<ll> A,B;
ll H,M,HH,MM;
ll now;
ll INF = 1e18;

 
int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(N%2==0){
        cout << (B[N/2]+B[N/2-1]) - (A[N/2]+A[N/2-1])+ 1<< endl;
    }else{
        cout << B[N/2] - A[N/2] + 1 << endl;
    }
    
}


Measured memory_bytes: 6548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0326
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nf = RArInt();
            int n = nf[0], f = nf[1];

            Dictionary<string, int> pairs = new Dictionary<string, int>();
            for (int i = 0; i < n; i++)
            {
                string[] items = RArSt().Skip(1).ToArray();
                Array.Sort(items);
                for (int j = 0; j < items.Length; j++)
                {
                    for (int k = j + 1; k < items.Length; k++)
                    {
                        string key = items[j] + " " + items[k];
                        if (!pairs.ContainsKey(key)) pairs.Add(key, 0);
                        pairs[key]++;
                    }
                }
            }

            string[] res = pairs.Where(x => x.Value >= f).OrderBy(x => x.Key).Select(x => x.Key).ToArray();
            Console.WriteLine(res.Length);
            for (int i = 0; i < res.Length; i++) Console.WriteLine(res[i]);

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 21352
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    ll ac = 0, wa = 0;
    vll pen(n, 0);
    vll acc(n, 0);
    REP(i, m) {
        ll p;
        string s;
        cin >> p >> s;
        if (s == "WA") {
            if (acc[p - 1] == 0) pen[p - 1]++;
        } else {
            if (acc[p - 1] == 0) {
                ac++;
                acc[p - 1] = 1;
                wa += pen[p - 1];
            }
        }
    }
    cout << ac << ' ' << wa << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...) std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename Value, typename BinaryOp>
class valued_union_find_tree
{
  int                n;
  std::vector<Value> table;
  std::vector<int>   prt;
  BinaryOp           op;
  Value              id;

public:
  valued_union_find_tree (int n, BinaryOp op, Value id, Value init) :
    n(n), table(n, init), prt(n, -1), op(op), id(id)
    {}

  bool is_root (int x)        const {return prt.at(x) < 0;}

  int  size    (int x)        const {return -prt.at(find(x));}

  bool same    (int x, int y) const {return find(x) == find(y);}

  int  find    (int x)        const
  {
    while (!is_root(x)) x = prt.at(x);
    return x;
  }

  auto collect ()             const {return prt;}

  auto collect_vals ()        const {return table;}

  auto get     (int x)        const {return table.at(find(x));}

  void set     (int x, Value val)    {table.at(find(x)) = val;}

  // Returns `true` if x and y are newly connected.
  // y becomes the partent.
  bool unite   (int x, int y)
  {
    if ((x = find(x)) == (y = find(y))) return false;
    if (size(x) > size(y)) std::swap(x, y);
    prt.at(y) += prt.at(x);
    prt.at(x) = y;
    table.at(y) = op(table.at(y), table.at(x));
    table.at(x) = id;
    return true;
  }
};

template <typename Value, typename BinaryOp>
auto make_valued_union_find_tree(int n, BinaryOp op, Value id, Value init)
{
  return valued_union_find_tree<Value, BinaryOp>(n, op, id, init);
}

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, h, w;
  std::cin >> n >> h >> w;
  auto queries = std::vector<std::tuple<int, int, int>>(n);
  rep(i, 0, n)
  {
    int x, y, a;
    std::cin >> x >> y >> a;
    x--, y--, y += h;
    queries.at(i) = std::make_tuple(a, x, y);
  }
  auto uf = make_valued_union_find_tree
  (
    h + w,
    [](auto x, auto y){return x + y;},
    0,
    1
  );
  std::sort(queries.begin(), queries.end());
  std::reverse(queries.begin(), queries.end());
  auto sat = [&] (int x) -> bool
  {
    auto dif = uf.get(x) - uf.size(x);
    assert(dif == 0 || dif == 1);
    return dif;
  };
  lint ret = 0;
  for (auto tuple : queries)
  {
    int a, x, y;
    std::tie(a, x, y) = tuple;
    if (!uf.same(x, y) && (!sat(x) || !sat(y)))
    {
      uf.unite(x, y);
      ret += a;
    }
    else if (uf.same(x, y) && !sat(x))
    {
      assert(!sat(y));
      uf.set(y, uf.get(y) + 1);
      ret += a;
    }
  }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 2944
N, M = map(int, input().split())

ac_list = [False] * (N + 1)
ac_count = 0
penalty = [0] * (N + 1)

for i in range(M):
    problem, status = input().split()
    problem = int(problem)

    if status == "AC":
        if not ac_list[problem]:
            ac_count += 1
        ac_list[problem] = True
        continue

    if status == "WA" and not ac_list[problem]:
        penalty[problem] += 1

point = 0
for i, p in enumerate(penalty):
    if ac_list[i]:
        point += p

print(ac_count, point)


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

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

        vector<int> A(N);

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

        sort(A.rbegin(),A.rend());
        long long ans = 0;
        for(int i = 0; i < N - 1; i++) ans += A[(i+1)/2];
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 4000
MOD = 10 ** 9 + 7

def sieve(n):
    srn = int(n ** 0.5) + 1
    f = [False] * (srn + 1)
    res = []
    for i in range(2, srn + 1):
        if f[i]:
            continue
        res.append(i)
        for j in range(2 * i, srn + 1, i):
            f[j] = True
    return res

def trial_division(n):
    res = dict()
    for i in range(2, n+1):
        m = i
        pn = sieve(m)
        for p in pn:
            while m % p == 0:
                res[p] = res.get(p, 0) + 1
                m //= p
        if m > 1:
            res[m] = res.get(m, 0) + 1
    return res

N = int(input())
fn = trial_division(N)
res = 1
for f in fn.values():
    res *= (f + 1)
    res %= MOD
print(res)

Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	int num=0;
	while(n)
	{
		n/=2;
		num++;
	}
	ll ans=0;
	for(int i=1;i<=num;i++)
	{
		ans*=2;
		ans+=1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
'use strict';
let equalAll = (a, b, c) => {
  return a === b && a === c;
};
let equalSome = (a, b, c) => {
  return a === b || b === c || a === c;
};
let permutationSize = pattern => {
  if (equalAll(pattern[0], pattern[1], pattern[2])) {
    return 1;
  }
  if (equalSome(pattern[0], pattern[1], pattern[2])) {
    return 3;
  }
  return 6;
};
function Main(input) {
  const line = input.split(' ').map(el => +el);

  let patterns = [];
  for (let x = 0; x <= line[0]; x++) {
    if (x > line[1]) continue;
    for (let y = x; y <= line[0]; y++) {
      if (y > line[1]) continue;
      const z = line[1] - x - y;
      if (z < 0 || z > line[0]) continue;
      if (z < x || z < y) continue;
      patterns.push([x, y, z]);
    }
  }

  let result = 0;
  for (let i = 0; i < patterns.length; i++) {
    result += permutationSize(patterns[i]);
  }
  console.log(result);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 104772
n,m = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(m)]

l_max,r_min = 0,10**5
for l,r in src:
    l_max = max(l_max,l)
    
for l,r in src:    
    r_min = min(r_min,r)
else:
    if r_min-l_max < 0:
        print(0)
    else:
        print(r_min-l_max+1)

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    for ( int j = N - 1; j >= i; j-- ) {
      if ( A[j].value < A[j - 1].value ) {
        Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    int minj = i;
    for ( int j = i; j < N; j++ ) {
      if ( A[j].value < A[minj].value ) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] =t;
  }
}

void print(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

// ????????????????????¨?????????????????????????????????
bool isStable(struct Card C1[], struct Card C2[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( C1[i].suit != C2[i].suit ) return false;
  }
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;
  
  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    cin >> C1[i].suit >> C1[i].value;
  }

  for ( int i = 0; i < N; i++ ) C2[i] =C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) ) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
int main(){
	int x, y;
	do{
		std::cin >> x >> y;
		if (!x && !y){
			break;
		}
		if (x > y){
			std::cout << y << ' ' << x << '\n';
		}
		else{
			std::cout << x << ' ' << y << '\n';
		}
	} while (1);
}


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

int main(int argc, char *argv[])
{
    int n;
    double x[1001], y[1001];

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%lf", &x[i]);
    for (int i = 0; i < n; i++)
        scanf("%lf", &y[i]);

    double d, d1 = 0, d2 = 0, d3 = 0, di = 0;
    for (int i = 0; i < n; i++) {
        d = fabs(x[i] - y[i]);
        d1 += d;
        d2 += d * d;
        d3 += d * d * d;
        di = d > di ? d : di;
    }
    printf("%.8f\n", d1);
    printf("%.8f\n", sqrt(d2));
    printf("%.8f\n", cbrt(d3));
    printf("%.8f\n", di);

    return 0;
}



Measured memory_bytes: 2092
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

MOD = 10 ** 9 + 7

N, K = map(int, input().split())

def sum_1_to_n(n):
    return n * (n + 1) // 2


ans = 0
for k in range(K, N + 2):
    tmp = sum_1_to_n(k - 1)
    start = tmp
    end = N * k - tmp
    # print(start, end)
    ans += end - start + 1
    ans %= MOD
    # print("ans = ", ans)

print(ans)





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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long long ans = 0;
  long long tmp = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) {
      ans += tmp / 2;
      tmp = 0;
    }
    else tmp += A.at(i);
    if (i == N - 1) ans += tmp / 2;
  }
  cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

char __buffer[100000];

#ifdef _DEBUG
#define LOCAL
#endif

void err(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);
	
	fprintf(stderr, "\t%s", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);
	
	fprintf(stderr, "\t%s\n", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln() {
#ifdef LOCAL	
	fprintf(stderr, "\n");
#endif	
}

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 141;

int n, x;
int a[MAX];
int ans;

void solve() {
	sort(a + 1, a + n + 1);
	
	fi(1, n - 1) {
		if (x >= a[i]) {
			ans++;
			x -= a[i];
		}
	}
	if (x == a[n]) ans++;
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

  scanf("%d %d", &n, &x);
  fi(1, n) {
  	scanf("%d", &a[i]);
  }
	solve();

	exit();
	return 0;
}





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

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

    if (s == "SUN") cout << 7 << endl;
    else if (s == "MON") cout << 6 << endl;
    else if (s == "TUE") cout << 5 << endl;
    else if (s == "WED") cout << 4 << endl;
    else if (s == "THU") cout << 3 << endl;
    else if (s == "FRI") cout << 2 << endl;
    else if (s == "SAT") cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split()))for i in range(n)]
'''
a　価格
b　上限本数
'''
ans = 0
ab.sort()
i = 0
while m > 0:
  a = ab[i][0]
  b = ab[i][1]
  if m >= b:
    m -= b
    ans += a*b
  else:
    ans += a*m
    m = 0
  i += 1
print(ans)

Measured memory_bytes: 61068
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#include <stack>
#include <queue>
#include <algorithm>
#include <vector>
#include <list>
using namespace std;

typedef pair<int,int> P;
typedef long long lint;

int n;
double th=M_PI*60/180;
struct point {double x,y; };
void get_input() {
    scanf("%d",&n);
}

/*
点(a,b)?原点逆??旋?x度的旋?公式是：
 -              -     - -
| cos(x) -sin(x) | * | a |
| sin(x)  cos(x) |   | b |
 -              -     - -
*/


void koch(int depth,point beg,point end) {
    if(depth==0) return;
    point s,t,u;
    s.x=(2*beg.x+end.x)/3;
    s.y=(2*beg.y+end.y)/3;
    t.x=(beg.x+2*end.x)/3;
    t.y=(beg.y+2*end.y)/3;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

    koch(depth-1,beg,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(depth-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(depth-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(depth-1,t,end);

}

void solve() {
    point a,b;
    a.x=0; a.y=0;
    b.x=100; b.y=0;

    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
}

void display_output() {

}

int main() {
#ifdef debug
    freopen("in.txt","r",stdin);
#endif
    get_input();
    solve();
    display_output();
}

Measured memory_bytes: 2960
def main():
    import sys
    import math
    input = sys.stdin.readline
 
    n, d = [int(i) for i in input().split()]
    
    table = [[int(i) for i in input().split()] for n in range(n)]
 
    count = 0
    
    for i in range(n):
        for j in range(i+1, n):
            temp = 0
            for x in range(d):
                temp += (table[i][x] - table[j][x]) ** 2
          
            rt = math.sqrt(temp)
            if rt.is_integer():
                count += 1
    
    print(count)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  queue<pair<string, int> > queue;
  for(int i=0;i < n;i++){
    string name; int time;
    cin >> name >> time;
    queue.push(make_pair(name,time));
  }
  int now = 0;
  while(!queue.empty()){
    pair<string, int> que = queue.front(); queue.pop();
    if(que.second <= q){
      now += que.second;
      cout << que.first << " " << now << endl;
    }else{
      que.second -= q;
      queue.push(que);
      now += q;
    }
  }
	return 0;
}

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

int main() {
    int N;
    int len, ans;
    string S;
    cin >> N;
    cin >> S;
    ans=0;
    for(int i=1; i<N; i++){
        len=0;
        for(int j=0; j<N-i; j++){
            if(S[j]==S[j+i]){
                len++;
            }else{
                len=0;
            }
            if(len>ans){
                ans = len;
            }
            if(len==i){
                len=0;
            }
            //cout << S[j+i];
        }
        //cout << endl;
    }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint n, m, d;
    cin >> n >> m >> d;

    long double res = m-1;

    if (d == 0) {
        res /= n;
    }
    else {
        res *= 2 * (n-d);
        res /= n * n;
    }

    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

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

int main(void){
  int pos[110]={0};
  int c[10]={0};
  int n;
  
  for (int i=1; i<=9; i++){
    int t;
    cin >> t;
    pos[t]=i;
  }
  cin >> n;
  for (int i=0; i<n; i++){
    int t;
    cin >> t;
    c[pos[t]]=1;
  }
  cout << (((c[1]&&c[2]&&c[3])||
            (c[4]&&c[5]&&c[6])||
            (c[7]&&c[8]&&c[9])||
            (c[1]&&c[4]&&c[7])||
            (c[2]&&c[5]&&c[8])||
            (c[3]&&c[6]&&c[9])||
            (c[1]&&c[5]&&c[9])||
            (c[3]&&c[5]&&c[7]))? "Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
//AtCoder ABC071 A - Meal Delivery
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll x,a,b;
    cin>>x>>a>>b;
    auto la=abs(x-a);
    auto lb=abs(x-b);
    cout<<(la<lb?"A":"B")<<endl;
    return 0;
}

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

int n,m;

int main()
{
	ios::sync_with_stdio(false);
	while(cin>>n>>m){
		int ans=1,t,q=sqrt(m);
		for(int i=1;i<=q;++i)
			if(m%i==0){
				t=m/i;
				if(t>=n)	ans=max(ans,i);
				if(i>=n)	ans=max(ans,t);
			}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	int i = 0;
	int s = 2;
	for (i = 0; s <= n; i ++)
	{
		s *= 2;
	}

	cout << (int)pow(2, i) << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
	int n,i;
	scanf("%d",&n);
	for(i=1; i<=n+1; i++){
		if(i*i>n){
			printf("%d\n",(i-1)*(i-1));
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
typedef long double ld;
signed main()
{
  int n,m;
   cin >> n>>m;
   if(n==2){
     n=1;  
   }else if(n<=1){
      n=0;
   }else{
    n=n*(n-1)/2;
   }
   if(m<=1){
     m=0;
   }else{
       m=m*(m-1)/2;
   }
cout << m + n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

void dfs(const vector<vector<int>>& graph, vector<bool>& visited, int i) {
  visited[i] = true;
  for (auto node : graph[i]) {
    if (!visited[node]) {
      dfs(graph, visited, node);
    }
  }
}

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<P> edge(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[i] = P(a, b);
  }
  int ans = 0;

  for (int i = 0; i < M; i++) {
    vector<vector<int>> graph(N);
    vector<bool> visited(N, false);
    for (int j = 0; j < M; j++) {
      if (j == i) continue;
      graph[edge[j].first].push_back(edge[j].second);
      graph[edge[j].second].push_back(edge[j].first);
    }
    dfs(graph, visited, 0);
    ans += count(visited.begin(), visited.end(), true) == N ? 0 : 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256