akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
//1001 Exponentiation
namespace OJ_C_Sharp {
    class Program {
        
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            int[] a = new int[N];
            for (int i = 0; i < N;i++){
                a[i] = int.Parse(input[i]);
            }
            int min = a[0];
            int max = a[0];
            int min_index = 1;
            int max_index = 1;
            for (int i = 1; i < N;i++){
                if (min>a[i]){
                    min = a[i];
                    min_index = i + 1;
                }
                if(max<a[i]){
                    max = a[i];
                    max_index = i + 1;
                }
            }
            int m = 2 * N - 1;
            if (System.Math.Abs(min)>System.Math.Abs(max)){
                Console.WriteLine(m);
                for (int i = 1; i <= N;i++){
                    Console.WriteLine("{0} {1}",min_index,i);
                }
                for (int i = N; i > 1;i--){
                    Console.WriteLine("{0} {1}",i,i-1);
                }
            }
            else {
                Console.WriteLine(m);
                for (int i = 1; i <= N ;i++){
                    Console.WriteLine("{0} {1}",max_index,i);
                }
                for (int i = 1; i < N;i++){
                    Console.WriteLine("{0} {1}",i,i+1);
                }
            }
        }
    }
}


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

int main() {
    int groupNum;
    int totalPeopleNum = 0;
    
    cin >> groupNum;
    
    for (int i = 0; i < groupNum; i++) {
	    int start, end;
	    cin >> start >> end;
	    
	    int peopleInTheGroup = end - start + 1;
	    totalPeopleNum += peopleInTheGroup;
    }
    
    cout << totalPeopleNum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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


Measured memory_bytes: 27088
# -*- Coding: utf-8 -*-


def main():
    num_list = []
    num_list = [int(i) for i in input().split()]  #標準入力を行う
    num_list.sort()
    print('{0} {1} {2}'.format(num_list[0], num_list[1], num_list[2]))


main()


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

int main(){
	string s;
	cin>>s;
	
	int nw=1000;
	int ans=1000;
	for(int i=0;i<s.size()-2; i++){
		string sx=s.substr(i,3);
		int nx=stoi(sx);
		nw=abs(753-nx);
		ans = min(nw, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	var cnt int
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	t := strings.ToUpper(sc.Text())
	for {
		sc.Scan()
		text := sc.Text()
		if text == "END_OF_TEXT" {
			break
		}
		for _, word := range strings.Split(strings.ToUpper(text), " ") {
			if t == word {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
	return
}



Measured memory_bytes: 1108
using System;
using System.Linq;

namespace ABC070_A
{
    class Program
    {
        static string Solve()
        {
            string input = Console.ReadLine();
            string revInput = string.Join("", input.Reverse());
            if (input.Equals(revInput))
            {
                return "Yes";
            }
            return "No";
        }
        static void Main(string[] args)
        {
            Console.WriteLine(Solve());
        }
    }
}


Measured memory_bytes: 11220
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

score = 0

m = int(n / 2)

for i in range(m):
  score += a[i] * 2

if n % 2 == 1:
  score += a[m]
  
score -= a[0]

print(score)

Measured memory_bytes: 94272
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
T = [int(input()) for _ in range(D)]
v = 0
last = [0] * 26
for d in range(D):
    # ct:current type
    ct= T[d] - 1
    last[ct] = d + 1
    # 今回の満足度
    v += S[d][ct]
    # 不満度を引く
    v -= sum([C[t] * (d + 1 - last[t]) for t in range(26)])
    print(v)

Measured memory_bytes: 9252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int x;
    cin >> x;

    int happiness = 0;
    happiness += 1000 * (x / 500);
    x = x % 500;
    happiness += 5 * (x / 5);
    cout << happiness << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,m,sum;
	while(cin>>sum>>n>>m)
	{
		int ans1,ans2;
		ans1=min(n,m);
		cout<<ans1<<" ";
		if(n+m>sum)
		{
			cout<<n+m-sum<<endl;	
		}
		else 
		{
			cout<<"0"<<endl;
		}
	}
	return 0;	
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll s[205000];
ll a[205000];
int main()
{
	ll n,k,x;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[i]=x;
	}
	int g=1,h=0,flag=0;
	while(k--)
	{
		s[g]++;
		if(flag)
		{
			h++;
		}
		g=a[g];
		if(s[g]==2)
		{
			flag=1;
		}
		if(s[g]==3)
		{
			break;
		}
	}
	if(k>0)
	{
		k%=h;
	}
	for(int i=0;i<k;i++)
	{
		g=a[g];
	}
	cout<<g<<endl;
	return 0;	
}

Measured memory_bytes: 6740
let () =
  let chk = Array.make 4 0 in
  Scanf.scanf "%d" (fun n -> Array.init n (fun _ -> Scanf.scanf " %c" (String.index "PWGY")))
  |> Array.iter (fun x -> chk.(x) <- 1);
  Array.fold_left (+) 0 chk |> (fun x -> if x = 3 then "Three" else "Four")
  |> print_endline

Measured memory_bytes: 384
def main():
    n,k = map(int, input().split())
    MOD = 10**9+7
    NMAX = 2*2*10**5

    fact = [0 for i in range(NMAX+5)]
    fact[0] = 1
    invfact = [0 for i in range(NMAX+5)]
    invfact[0] = 1

    for i in range(NMAX):
        fact[i+1] = (fact[i]*(i+1))%(MOD)

    invfact[NMAX] = pow(fact[NMAX], MOD-2, MOD)
    for i in range(NMAX-1,0,-1):
        invfact[i] = (invfact[i+1] * (i+1)) % MOD

    ans = 0
    if k >= n:
        k = n-1
    for i in range(k+1):
        z = fact[n]*invfact[i]%MOD
        z = z*invfact[n-i]%MOD
        h = fact[n-1]*invfact[i]%MOD
        h = h*invfact[n-i-1]%MOD
        ans += z*h%MOD

    print(ans%MOD)

main()

Measured memory_bytes: 71128
import sys
sys.setrecursionlimit(3000)
def dfs(r, c, n):
    board[r][c] = n
    drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if 0 <= nr < h and 0 <= nc < w and board[nr][nc] != n:
            if board[nr][nc] in 'WB':
                pile.append(board[nr][nc])
                continue
            dfs(nr, nc, n)

while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0: break
    board = [list(input()) for _ in range(h)]
    place = 0
    piles = []
    black, white = [], []
    for r in range(h):
        for c in range(w):
            if board[r][c] == '.':
                pile = []
                place += 1
                dfs(r, c, place)
                piles.append(pile)

    for i, pile in enumerate(piles):
        if not pile: continue
        if all(p == 'B' for p in pile):
            black.append(i+1)
        elif all(p == 'W' for p in pile):
            white.append(i+1)

    ans_b, ans_w = 0, 0
    for row in board:
        for c in row:
            if c in black:
                ans_b += 1
            elif c in white:
                ans_w += 1
    print(ans_b, ans_w)

Measured memory_bytes: 9400
# AOJ 0061 Rank Checker
# Python3 2018.6.15 bal4u

team = {}
while True:
	p, s = list(map(int, input().split(',')))
	if p == 0: break
	team[p] = s
tbl = sorted(team.items(), key=lambda x:x[1], reverse=True)

ans = [0]*101
ans[tbl[0][0]] = ord = 1
for i in range(1,len(tbl)):
	if tbl[i][1] < tbl[i-1][1]: ord += 1
	ans[tbl[i][0]]= ord
	
while True:
    try:
        print(ans[int(input())])
    except EOFError:
        break


Measured memory_bytes: 5596
Q = int(input())
X = [list(map(int, input().split())) for _ in range(Q)]

def sieve(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        if not is_prime[i]:
            continue

        for j in range(2 * i, n + 1, i):
            is_prime[j] = False
    return is_prime

primes = sieve(10 ** 5)
likes = [primes[n] & primes[(n + 1) // 2] if n %  2 != 0 else False
         for n in range(10 ** 5)]
cumsum = [0] * (10 ** 5 + 1)
for i in range(10 ** 5):
    cumsum[i + 1] = cumsum[i] + int(likes[i])

for l, r in X:
    print(cumsum[r + 1] - cumsum[l])


Measured memory_bytes: 70744
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    ll x, k, d; cin >> x >> k >> d;
    
    x = abs(x);

    if(k <= x / d){
        put(abs(x - k * d));
    }else{
        ll point = x % d;
        ll cnt = x / d;
        if((k-cnt) % 2 == 0){
            put(point);
        }else{
            put(abs(point - d));
        }
        //cout << "point:" << point << " cnt:" << cnt << endl;
    }
}

Measured memory_bytes: 3564
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<int> l(n,0),r(n,0),ch(n,0);
    rep(i,n) cin>>l[i]>>r[i];
    rep(i,n)if(l[i]==r[i]) ch[i]=1;
    rep(i,n-2){
        if(ch[i]==1 && ch[i+1]==1 && ch[i+2]==1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

using namespace std;
const int N=2e5+10;
int a[N];
const int MAX=1e9+10;
vector <int> g[N];
int f[N];
int n;
int ans[N];
void dfs(int fa,int now){
    int pos=lower_bound(f,f+n+1,a[now])-f;
    int tmp=f[pos];
    f[pos]=min(a[now],f[pos]);
    for(int i=0;i<g[now].size();i++){
        if(g[now][i]==fa) continue;
        dfs(now,g[now][i]);
    }
    ans[now]=lower_bound(f,f+n+1,MAX)-f-1;
    f[pos]=tmp;
}
int main()
{
    char a,b,c;
    cin>>a>>b>>c;
    if(b=='B') cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}


Measured memory_bytes: 8324
#include "bits/stdc++.h"
using namespace std ;
const int N=1e5+5, M = 1e5, OO = 0x3f3f3f3f;
long long  mem[101][N];
int Profit[N], Weight[N], n, k;
long long knapsack(int i = n-1, int rem = k)
{
    if(i < 0)
        return 0;
    long long &ret = mem[i][rem];
    if (ret != -1)
        return ret;
    ret = knapsack(i - 1, rem);
    if(rem - Weight[i] >= 0)
        ret = max(ret , knapsack(i - 1, rem - Weight[i]) + Profit[i]);
    return	ret;
}
int main()
{
    scanf("%d %d", &n, &k);
    memset(mem, -1, sizeof mem);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d %d", Weight+i, Profit+i);
    cout<<knapsack();

}


Measured memory_bytes: 79104
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func copy(a, b []int) {
	for i := range a {
		a[i] = b[i]
		b[i] = 0
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()
	a := nextInts(n)

	b := make([]int, n)
	for i := 0; i < min(k, 41); i++ {
		for j := 0; j < n; j++ {
			l, r := max(0, j-a[j]), min(n, j+a[j]+1)
			b[l]++
			if r < n {
				b[r]--
			}
		}
		for j := 1; j < n; j++ {
			b[j] += b[j-1]
		}
		copy(a, b)
	}

	for i := 0; i < n-1; i++ {
		putf("%d ", a[i])
	}
	puts(a[n-1])
}


Measured memory_bytes: 7356
using Atcoder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().Split(' ');
            var N = int.Parse(S[0]);
            var Y = int.Parse(S[1]);

            for (int x = 0; x <= N; x++)
            {
                for (int y = 0; y <= N; y++)
                {
                    if ((x + y) > N)
                    {
                        break;
                    }
                    var z = N - (x + y);
                    if (Y == 10000 * x + 5000 * y + 1000 * z)
                    {
                        Console.Write(x.ToString() + " " + y.ToString() + " " + z.ToString());
                        return;
                    }
                }
            }
            Console.Write("-1 -1 -1");

            //Console.Write(result);
            }


    }



    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
}


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

int gcd(int a, int b) {
  int big = (a > b) ? a : b;
  int small = (a > b) ? b : a;
  int mod = big % small;
  if (mod == 0) {
    return small;
  }
  return gcd(small, mod);
}

int main() {
  // monsters
  int n,i;
  cin >> n;
  int health[n];
  for (i = 0; i < n; i++) {
    cin >> health[i];
  }

  int g = health[0];
  for (i = 1; i < n; i++) {
    g = gcd(g, health[i]);
    if (g == 1) {
      cout << 1;
      return 0;
    }
  }
  cout << g;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = ((result) * (x));
    
    x=((x)*(x));
    
    n >>= 1;
  }
  return result;
}
ll gcd(ll a,ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}
ll f(ll n){
  ll c = 0;
  while(n>0)n/=10 , c++;
  return c;
}
vector<vector<ll>>g;
vector<bool>vis;
map<pll,ll>colour;
ll n;
void bfs(ll s){
  queue<ll>q;
  q.push(s);
  
  while(!q.empty()){
    ll f = q.front();
    q.pop();
    vis[f] = 1;
    set<ll>st;
    for(auto &x:g[f]){
      if(!vis[x])q.push(x);
      if(colour[{f,x}]!=0)st.insert(colour[{f,x}]);
    }
    ll c = 1;
    for(auto &x:g[f]){ 
      if(colour[{f,x}]!=0)continue;
      while(st.find(c)!=st.end())c++;
      colour[{f,x}] = colour[{x,f}] = c;
      st.insert(c);
    }
    //for(auto &x:g[f])cout << x << ':' << colour[{f,x}] << '\n';
    //cout << '\n';
  }
}
int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  
 
  cin >> n;
  g = vector<vector<ll>>(n+1,vector<ll>());
  vis = vector<bool>(n+1,false);
  vector<pll>prec(n-1);
  for(ll i=0 ; i<n-1 ; i++){
    ll x,y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    prec[i] = {x,y};
  }
  ll res = 0;
  bfs(1);
  for(ll i=0 ; i<n-1 ; i++){
    res = max(res , colour[prec[i]]);
  }
  cout << res << '\n';
  for(auto &x:prec){
    cout << colour[x] << '\n';
  }
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N,A,B,C,D;
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;

	string S;
	cin >> S;

	ll n = S.size();
	repk(i,A,max(C,D)){
		if(S[i] == '#' && S[i+1] == '#'){
			cout << "No" << endl;
			return 0;
		}
	}

	if(C < D){
		cout << "Yes" << endl;
		return 0;
	} 
	else{
		repk(i,B-1,D){
			if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.'){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

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

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
string S[300];
int val[300][300];

int main() {
	cin >> N;
	REP(i, N) cin >> S[i];
	
	REP(i, N) REP(j, N) {
		int cnt = 0;
		REP(k, N) {
			if (S[i][(j + k) % N] == S[(i + k) % N][j]) cnt++;
			else break;
		}
		val[i][j] = cnt;
	}
	
	int ans = 0;
	REP(i, N) REP(j, N) {
		bool ok = true;
		REP(k, N) {
			if (val[(i + k) % N][(j + k) % N] < N - k) ok = false;
		}
		if (ok) ans++;
	}
	
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 768
n, m = map(int, input().split())

X = list(map(int, input().split()))

X = sorted(X)

A = []
B = []
for i in range(m - 1):
    A.append(X[i+1] - X[i])
    B.append(i)

A = sorted(A)

if n == 1:
    print(sum(A))
else:
    print(sum(A[:-n + 1]))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll mod = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  V<int> a(m), b(m);
  rep(i, m) {
    int ai, bi;
    cin >> ai >> bi;
    a[i] = ai - 1;
    b[i] = bi - 1;
  }
  V<set<int>> f(n);
  rep(i, m) {
    f[a[i]].insert(b[i]);
    f[b[i]].insert(a[i]);
  }

  int ans = 1;
  V<bool> checked(n, false);
  rep(i, n) {
    if (checked[i]) continue;
    int size = 0;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int p = q.front();
      q.pop();
      for (auto r : f[p]) {
        if (checked[r]) continue;
        checked[r] = true;
        q.push(r);
        size++;
      }
    }

    ans = max(ans, size);
  }
  cout << ans << endl;
}


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

using namespace std;

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

int L,N;
ll P[10001];
ll D[10001];
ll T[10001];
vector<pll> G[10001];
map<ll,ll> posToIdx;
ll idxToPos[10001];
ll d[10001];


ll dijkstra(int s,int g){
  const ll INF=1LL<<60;
  for(int i=0;i<10001;i++)d[i]=INF;
  priority_queue<pll,vector<pll>,greater<pll> > pq;
  pq.push(make_pair(0,s));
  d[s]=0;
  while(pq.size()){
    pll p = pq.top();pq.pop();
    ll cpos=p.second;
    ll ccost=p.first;
    if(d[cpos]<ccost)continue;
    for(pll np : G[cpos]){
      ll ncost=np.second+ccost;
      int npos=np.first;
      if(d[npos]>ncost){
        d[npos]=ncost;
        pq.push(make_pair(d[npos],npos));
      }
    }
  }
  return d[g];
}

int main(){

  cin>>L>>N;
  for(int i=0;i<N;i++)
    cin>>P[i]>>D[i]>>T[i];
  set<ll> st;
  int sz=0;
  for(int i=0;i<N;i++){
    if(posToIdx.count(P[i])==0){
      posToIdx[P[i]]=sz;
      idxToPos[sz]=P[i];
      sz++;
    }
    if(posToIdx.count(P[i]+D[i])==0){
      posToIdx[P[i]+D[i]]=sz;
      idxToPos[sz]=P[i]+D[i];
      sz++;
    }
  }
  if(posToIdx.count(0)==0){
    posToIdx[0]=sz;
    idxToPos[sz]=0;
    sz++;
  }
  if(posToIdx.count(L)==0){
    posToIdx[L]=sz;
    idxToPos[sz]=L;
    sz++;
  }
  vector<ll> v;
  for(pair<ll,ll> p : posToIdx){
    v.push_back(p.first);
  }
  for(int i=0;i<(int)v.size()-1;i++){
    int cur=i;
    int nxt=i+1;
    int from=posToIdx[v[cur]];
    int to=posToIdx[v[nxt]];
    G[from].push_back(make_pair(to,v[nxt]-v[cur]));
  }
  for(int i=0;i<N;i++){
    int from=posToIdx[P[i]];
    int to=posToIdx[P[i]+D[i]];
    G[from].push_back(make_pair(to,T[i]));
  }
  cout<<dijkstra(posToIdx[0],posToIdx[L])<<endl;
  
  return 0;
}


Measured memory_bytes: 1868
N = int(input())
a = list(map(lambda x : int(x) // 400, input().split()))
over3200 = sum(list(map(lambda x: 1 if x >= 8 else 0, a)))

count = 0
for i in range(8):
    if i in a:
        count += 1

print(max(1, count), count+over3200)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int n;
ll sum[440][440];
ll dp[440][440];
int main(){
    cin >> n;
    vl a(n);rep(i,n) cin >> a[i];
    for(int l=0;l<n;l++){
        sum[l][l+1]=a[l];
        for(int r=l+2;r<=n;r++){
            sum[l][r]=sum[l][r-1]+a[r-1];
        }
    }
    for(int width=2;width<=n;width++){
        for(int l=0;l+width<=n;l++){
            int r=l+width;
            dp[l][r]=LINF;
            for(int m=l+1;m<r;m++){
                dp[l][r]=min(dp[l][r],dp[l][m]+dp[m][r]+sum[l][r]);
            }
        }
    }
    cout << dp[0][n] << endl;
    return 0;
}

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

struct Time {
    int h, m, s;
};

int main() {
    Time arrives[3], leaves[3];
    for (int i = 0; i < 3; i++) {
        cin >> arrives[i].h >> arrives[i].m >> arrives[i].s
            >> leaves[i].h >> leaves[i].m >> leaves[i].s;
    }
    int workSeconds[3] = {};
    for (int i = 0; i < 3; i++) {
        workSeconds[i] = (leaves[i].h - arrives[i].h) * 3600 + (leaves[i].m - arrives[i].m) * 60 + (leaves[i].s - arrives[i].s);
    }
    for (int i = 0; i < 3; i++) {
        printf("%d %d %d\n", workSeconds[i] / 3600, (workSeconds[i] % 3600) / 60, workSeconds[i] % 60);
    }
}

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

namespace ABC165A
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int i = 1;
            int hikyori = 0;
            int hantei = -1;
            while (hikyori <= 1000)
            {
                hikyori = K * i;
                if (hikyori >= A & hikyori <= B)
                {
                    hantei = 0;
                }
                i += 1;
            }
            if (hantei == 0)
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("NG");
            }
        }
    }
}


Measured memory_bytes: 27536
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        int a = 0;
        int b = 0;
        sc.close();
        boolean ebi = false;
        for(int i = -120 ; i < 120 && ebi == false; i++){
            for(int j = -120 ; j < 120 && ebi == false; j++ ){
                if(i * i * i * i * i - j * j * j * j * j == x){
                    a = i;
                    b = j;
                    ebi = true;
                }
            }
        }
        System.out.println(a + " " + b);
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i); 
        sum ^= a.at(i);
    }
    
    for (int i = 0; i < N; i++) {
        int b = sum ^ a.at(i);
        cout << b << ' ';
    }
    cout << endl;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

void printYes(){
	cout<<"Yay!"<<endl;
}
void printNo(){
	cout<<":("<<endl;
}

signed main(){

	lli n;
	string s;
	cin>>n>>s;

	REP(i,0,s.size()){
		lli index = (s.at(i)-'A'+n)%26;
		cout<<(char)('A'+index);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using std::cout;
using std::endl;

const int p=1e9+7;
const int MAXN=10010;
int n;
struct Edge{
	int to;
	int nxt;
}edge[MAXN];
int frm[MAXN];
int cnt;
long long H[MAXN];
int siz[MAXN];
long long dp[MAXN>>1][MAXN>>1];
long long tmp[MAXN]; 
long long ans; 

void insert(int u,int v){
	cnt++;
	edge[cnt].to=v;
	edge[cnt].nxt=frm[u];
	frm[u]=cnt;
} 

void pre(){
	H[0]=1;
	for(int i=2;i<=n;i+=2){
		H[i]=(H[i-2]*(i-1))%p;//考虑第i个点有i-1种连边方式，还剩i-2个点没连边 
	}
}

void Dp(int u,int fa){//树形DP的时候如果要合并子树答案，要用一个临时数组记录昂 
	siz[u]=1;
	dp[u][1]=1;//但是不是不可能有1嘛wsl又 
	//但这里是不考虑u所在联通块的答案嘛qwq 
	for(int i=frm[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v!=fa){
			Dp(v,u);
			for(int szu=1;szu<=siz[u];szu++){
				for(int szv=1;szv<=siz[v];szv++){
					if(!(szv&1))tmp[szu]=(tmp[szu]+(-1*dp[u][szu]*dp[v][szv])%p*H[szv]%p)%p;//v所在联通块自己连边，所以大小必须为偶数
					tmp[szu+szv]=(tmp[szu+szv]+(dp[u][szu]*dp[v][szv])%p)%p;
				}
			}
			siz[u]+=siz[v];//先加siz再处理下面这一段 
			for(int szu=1;szu<=siz[u];szu++){
				dp[u][szu]=tmp[szu];
				tmp[szu]=0;
			}
		}
	}
	//cout<<u<<' '<<dp[u][1]<<' '<<dp[u][2]<<endl;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		insert(u,v);
		insert(v,u);
	}
	pre();
	Dp(1,0);
	for(int szr=2;szr<=n;szr+=2){
		ans=((ans+dp[1][szr]*H[szr]%p)%p+p)%p;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 194816
#include<iostream>
#include<string>
#include<cstdlib>
#include<math.h>
using namespace std;
int main(void){
    int n,a,b,ans=0,temp,index;
    cin >> n >> a >> b;
    
    for(int i=1;i<=n;i++){
            temp=0;
            index=i;
        while(index){
            temp+=index%10;
            index=index/10;
        }
        if(a<=temp&&temp<=b){
            ans+=i;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
import re
s=input()
if re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s):
    print("YES")
else:print("NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define CIN>>x scanf("%lld",&x);
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    string s,T,W,C,K;
	cin>>s;
	cin>>q;
	a=0;
	while(q--){
		cin>>x;
		if(x==1){
			a++;
		}
		else{
			cin>>y;
			if((a+y)%2==0){
				cin>>C;
				T=T+C;
			}
			else{
				cin>>C;
				W=C+W;
			}
		}
	}

	if(a%2==0)cout<<W+s+T<<endl;
	else{
		K=W+s+T;
		reverse(all(K));
		cout<<K<<endl;
	}
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i, 1, n + 1) FOR(j, 1, n + 1) FOR(k, 1, n + 1) {
    ans += gcd(i, gcd(j, k));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

int size = 0;

struct Cust{
  int num,total,flg;
}c[1000],tmp;

int find(struct Cust x){
  int i;

  for(i=0;i<size;i++){
    if(c[i].num == x.num) return i;
  }
  return -1;
}

void insert(struct Cust x){
  int i;

  x.total = 1;
  x.flg = 0;

  for(i=size++;i>0 && c[i-1].num > x.num;i--){
    c[i] = c[i-1];
  }
  c[i] = x;
}

int main(void){
  int i,x,pos;
  char buff[64];

  memset(c,0,sizeof(c));
  while(1){
    fgets(buff,64,stdin);
    if(buff[0]<'0' || '9'<buff[0]) break;
    sscanf(buff,"%d,%d",&tmp.num,&x);

    if((pos=find(tmp)) == -1){
      insert(tmp);
    }
    else{
      c[pos].total++;
    }
  }

  while(1){
    if(fgets(buff,64,stdin) == NULL) break;
    sscanf(buff,"%d %d",&tmp.num,&x);

    if((pos=find(tmp)) != -1){
      c[pos].flg = 1;
      c[pos].total++;
    }
  }

  for(i=0;i<size;i++){
    if(c[i].flg) printf("%d %d\n",c[i].num,c[i].total);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
const ll mod = 1e9 + 7;

ll n, k;
ll a[maxn];
ll fact[maxn];
ll inv[maxn];


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

void init(){
    fact[0] = 1;
     for(int i = 1;i <= maxn ;i ++)
       fact[i] = fact[i - 1] * i % mod;
    inv[maxn] = quickpow(fact[maxn], mod - 2);
    for(int i = maxn - 1; i >= 0; i --)
        inv[i] = inv[i + 1] * (i + 1) % mod;
}

ll C(ll x, ll y){
    if(x < y)
        return 0;
    return fact[x] % mod * inv[y] % mod * inv[x - y] % mod;
}

int main()
{
  int n, k;
  init();
  scanf("%d%d",&n,&k);
  for(int i = 1; i <= n; i ++)  scanf("%lld",&a[i]);
  sort(a + 1, a + n + 1);
  ll ans = 0;
  for(int i = 1; i <= n; i ++){
    ans += a[i] * C(i - 1, k - 1) % mod;
    ans -= (a[i] * C(n - i, k - 1) % mod) ;
    ans = (ans % mod + mod) % mod;
  }
  printf("%lld\n", (ans + mod) % mod);
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  long long ans=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i){
      if(a[i-1]&&a[i]){
        ans++;
        a[i]--;
      }
    }
    ans+=a[i]/2;
    a[i]%=2;
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int order = 1;
  int ans = 0;
  string nums = "0123456789";
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      for(int k = 0; k < 10; k++){
        order = 1;
        for(char c : s){
          if(order == 1 && c == nums.at(i)){
            order++;
          }
          else if(order == 2 && c == nums.at(j)){
            order++;
          }
          else if(order == 3 && c == nums.at(k)){
            ans++;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

arr = [0, 0, 0]
ans = 1
mod = 10 ** 9 + 7

a.each do |e|
    ans = ans * arr.count(e) % mod
    break unless (i = arr.index(e))
    arr[i] += 1
end

puts ans

Measured memory_bytes: 8068
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=3e3+5;
char a[maxn],b[maxn];
int f[maxn][maxn];
void Input()
{
    cin >> (a+1) >> (b+1);
    int n=strlen(a+1);
    int m=strlen(b+1);
    FOR(i,1,n)
        FOR(j,1,m)
            f[i][j]=max({f[i-1][j],f[i][j-1],f[i-1][j-1]+(a[i]==b[j])});
    //cout << f[n][m];
    string res;
    while (n&&m) {
        if (f[n-1][m]==f[n][m]) --n;
        else if (f[n][m-1]==f[n][m]) --m;
        else if (f[n-1][m-1]+(a[n]==b[m])==f[n][m]) {
            if (a[n]==b[m]) res.push_back(b[n--,m--]);
            else --n,--m;
        }
    }
    reverse(res.begin(),res.end());
    cout << res;
}
void Solve()
{

}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}



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

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int nxt = 1, ans = 0;
    rep(i,n) {
        if (nxt == a[i]) {
            ++nxt;
        } else {
            ++ans;
        }
    }
    if (ans == n) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    // Your code here!
    int a, b;
    scanf("%d%d", &a, &b);
    int score = 0;
    
    if (a > b) {
        score += a--;
    } else {
        score += b--;
    }
    
    if (a > b) {
        score += a--;
    } else {
        score += b--;
    }
    
    printf("%d\n", score);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if (a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if (a < b) a = b;}
void fail() { cout << -1 << endl; exit(0); }

typedef pair<int, int> pii; typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9+7;
constexpr int MAX = 50050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1; constexpr int INF = 1e9 + 1;
//const int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	ll N; cin >> N;
	//N--;
	string ret;
	//N--;
	//if (N == 0) {
	//	print("a"); return;
	//}
	while (N) {
		int r = N % 26;
		if (r == 0) {
			r = 25;
			N--;
		}
		else r--;
		ret += 'a' + r;
		N /= 26;
	}
	VREVERSE(ret);
	print(ret);
}





signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//mt.seed((int)(time(0)));
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
char s[200010];
int main(){
	int i;
	scanf("%s",s);
	int now=0;
	for(i=0;s[i];i++)now=(now+s[i]-'0')%9;
	printf("%s",now==0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1924
#include "stdio.h"
#include "math.h"

struct Point{
  double x,y;
};

void executeKoch(int dimention, Point p_init, Point p_fin){
  if(dimention == 0){
    return;
  }
  
  Point s, u, t;

  s.x = (2.0 * p_init.x + 1.0 * p_fin.x ) / 3.0;
  s.y = (2.0 * p_init.y + 1.0 * p_fin.y ) / 3.0;
  t.x = (1.0 * p_init.x + 2.0 * p_fin.x ) / 3.0;
  t.y = (1.0 * p_init.y + 2.0 * p_fin.y ) / 3.0;

  double theta = M_PI * 60.0 / 180.0;

  u.x = (t.x-s.x) * cos(theta) - (t.y-s.y) * sin(theta) + s.x;
  u.y = (t.x-s.x) * sin(theta) + (t.y-s.y) * cos(theta) + s.y; 
   
  executeKoch(dimention-1, p_init, s);
  printf("%.8f %.8f\n", s.x, s.y);
  executeKoch(dimention-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  executeKoch(dimention-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  executeKoch(dimention-1, t, p_fin);
}

int main(void){
  
  int dimention;
  scanf("%d", &dimention);

  Point p_init, p_fin;

  p_init.x = 0.0;
  p_init.y = 0.0;

  p_fin.x = 100.0;
  p_fin.y = 0.0;

  printf("%.8f %.8f\n", p_init.x, p_init.y);
  executeKoch(dimention, p_init, p_fin);
  printf("%.8f %.8f\n", p_fin.x, p_fin.y);

  return 0;
}


Measured memory_bytes: 2604
#include <iostream>

int main(int argc, char **argv)
{
    int N;
    std::string S;
    std::cin >> N >> S;
    int sum = 0;
    for(int i = 0; i < N-2; i++){
        if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') sum++;
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int main(){
int N,K;
  cin>>N>>K;
  vector<int64_t>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  int64_t dp[N][K+1];
  for(int i=0;i<=K;i++){
  if(i<=a[0])
    dp[0][i]=1;
    else
      dp[0][i]=0;
  }for(int i=1;i<N;i++){
     int64_t sum=0;
    
    for(int j=0;j<=a[i];j++){
    sum=(sum+dp[i-1][j])%mod;
      dp[i][j]=sum;
    }for(int j=a[i]+1;j<=K;j++){
    sum=(sum+dp[i-1][j]-dp[i-1][j-a[i]-1]+mod)%mod;
      dp[i][j]=sum;
    }
  }cout<<dp[N-1][K]<<endl;
    return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

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


int main()
{
  ll X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  REP(i, X) cin >> A[i];
  REP(i, Y) cin >> B[i];
  REP(i, Z) cin >> C[i];
  sort(ALL(A), greater<ll>());
  sort(ALL(B), greater<ll>());
  sort(ALL(C), greater<ll>());
  vector<ll> v;
  REP(i, X) REP(j, Y) v.PB(A[i] + B[j]);
  sort(ALL(v), greater<ll>());
  vector<ll> ans;
  REP(i, min((ll)v.size(), K)) REP(j, min((ll)C.size(), K)) ans.PB(v[i] + C[j]);
  sort(ALL(ans), greater<ll>());
  REP(i, K) cout << ans[i] << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int k, a, b;
  cin >> k >> a >> b;

  bool t = true;
  fo(i, a, b+1) {
    if(i % k == 0) {
      cout << "OK" << endl;
      t = false;
      break;
    }
  }

  if(t) cout << "NG" << endl;

  return 0;
}


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

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

    if (b - a <= x) {
        if (b - a <= 0) {
            cout << "delicious" << endl;
        }
        else {
            cout << "safe" << endl;
        }
    }
    else {
        cout << "dangerous" << endl;
    }

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
int g[50][50], f[50][50];

int solve() {
    forn(i, n) forn(j, n) if (i == j) {
        f[i][j] = 0;
    } else if (g[i][j] == 1) {
        f[i][j] = 1;
    } else {
        f[i][j] = 1234;
    }
    forn(k, n) forn(i, n) forn(j, n) {
        f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
    }
    forn(i, n) forn(j, i) if (f[i][j] > 123) {
        return 1;
    }
    return 0;
}

int main() {
    scanf("%d%d", &n, &m);
    forn(i, m) {
        int from, to;
        scanf("%d%d", &from, &to), --from, --to;
        g[from][to] = g[to][from] = 1;
    }
    int ans = 0;
    forn(i, n) forn(j, i) if (g[i][j] == 1) {
        g[i][j] = g[j][i] = 0;

        ans += solve();

        g[i][j] = g[j][i] = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
using namespace std;

//const int mod=1000000007;
const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t,n,m,k,q,x,a,b,c,d;
    cin>>n>>a>>b;
    vector<int> vec(n+1);
    vec[0]=0;
    m=n-b+a+1;
    for (int i=1; i<m; i++) {
        vec[i]+=m-i;
    }
//    print(vec);
    for (int i=1; i<=n; i++) {
        if (i>a&&i<b) {
            for (int j=i-1; j>0; j--) {
                vec[min(i-j, b-i+1+abs(a-j))]++;
            }
        }
        if (i==b) {
            for (int j=i-1; j>a; j--) {
                vec[min(i-j, b-i+1+abs(a-j))]++;
            }
        }
        else if (i>b){
            for (int j=b-1; j>a; j--) {
                vec[min(i-j, i-b+1+abs(a-j))]++;
            }
        }
    }
    for (int i=1; i<n; i++) {
        cout<<vec[i]<<"\n";
    }
    return 0;
    
    
}
    


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dsync std::ios::sync_with_stdio(false); std::cin.tie(NULL);
#define pb push_back
#define mp make_pair
typedef long long ll;

//#define foi(a, b) for (LL i = a; a < b ? i < b : b > i; a < b ? i++ : i--)
//#define foj(a, b) for (LL j = a; a < b ? j < b : b > j; a < b ? j++ : j--)

using namespace std;

int main()
{
   dsync;
   int node, edge;
   cin >> node >> edge;
   vector<vector<int>> adj(node + 1);
   for (int i = 1; i <= edge; i++)
   {
      int a, b;
      cin >> a >> b;
      adj[a].pb(b);
      adj[b].pb(a);
   }

   queue<int> q;
   vector<bool> visited(node + 1, false);
   vector<int> distance(node + 1, 0);

   visited[1] = true;
   distance[1] = 0;
   q.push(1);

   while (!q.empty())
   {
      int s = q.front();
      q.pop();

      for (auto u : adj[s])
      {
         if (visited[u])
            continue;

         visited[u] = true;
         distance[u] = s;
         q.push(u);
      }
   }
   for (int x = 2; x <= node; x++)
   {
      if (distance[x] == 0)
      {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
   for (int x = 2; x <= node; x++)
   {
      cout << distance[x] << endl;
   }
   return 0;
}


Measured memory_bytes: 10172
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n,k = map(int,input().split())
    ans = min(k - n%k,n%k)
    print(ans)
 
if __name__ =='__main__':
    main()  

Measured memory_bytes: 3064
n, m = gets.split.map(&:to_i)
aryC = Array.new(n, 0)

m.times do |i|
  x, y = gets.split.map(&:to_i).sort
  if x == 1
    aryC[y - 1] += 1
    if aryC[y - 1] == 2
      puts :POSSIBLE
      exit
    end
  elsif y == n
    aryC[x - 1] += 1
    if aryC[x - 1] == 2
      puts :POSSIBLE
      exit
    end
  end
end

puts :IMPOSSIBLE


Measured memory_bytes: 5372
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  unordered_map<int,int>mp;
  int n;
  cin>>n;
  ll ret = 0;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    int tt = i - x;
    ret += mp[tt];
    mp[x + i]++;
  }
  cout<<ret<<endl;
  return 0;
}

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



int main(){
    int64_t X;
    cin>>X;
    vector<int64_t> fitimes(130);
    for(int64_t i=0;i<130;i++){
        fitimes.at(i)=i*i*i*i*i;
    }
    //B<=0
    for(int i=0;i<130;i++){
        for(int j=i;j<130;j++){
            if(fitimes.at(i)+fitimes.at(j)==X){
                cout<<i<<' '<<-j<<endl;
                return 0;
            }
        }
    }
    //B>=>0
    for(int i=0;i<130;i++){
        for(int j=0;j<=i;j++){
            if(fitimes.at(i)-fitimes.at(j)==X){
                cout<<i<<' '<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632