akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
from collections import deque
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(H, W, Ch, Cw, Dh, Dw, data):
    # data = list(data.reshape(-1))
    N = HEIGHT * WIDTH
    visited = [0] * N

    start = (Ch + 1) * WIDTH + (Cw + 1)
    goal = (Dh + 1) * WIDTH + (Dw + 1)
    q = []
    nextJump = set()
    q.append(start)

    currentDistance = 0
    while True:
        while q:
            p = q.pop()
            if p == goal:
                return currentDistance
            if visited[p]:
                continue
            for dx in [-2, -1, 0, +1, +2]:
                for dy in [-WIDTH * 2, -WIDTH, 0, WIDTH, WIDTH * 2]:
                    nextJump.add(p + dx + dy)
            visited[p] = 1
            for d in [-1, +1, -WIDTH, +WIDTH]:
                if data[p + d] and not visited[p + d]:
                    q.append(p + d)

        # no continuous cell
        for p in nextJump:
            if not data[p]:
                continue
            if visited[p]:
                continue
            q.append(p)

        currentDistance += 1
        nextJump = set()
        if not q:
            return -1


def readMap(H, W):
    global SENTINEL, HEIGHT, WIDTH
    SENTINEL = 2
    HEIGHT = H + SENTINEL * 2
    WIDTH = W + SENTINEL * 2
    data = [0] * (HEIGHT * WIDTH)
    ok = ord(".")
    for i in range(H):
        S = input().strip()
        y = (i + SENTINEL) * WIDTH
        for j in range(W):
            data[y + (j + SENTINEL)] = 1 if S[j] == ok else 0
    return data


def main():
    # parse input
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    D = readMap(H, W)
    print(solve(H, W, Ch, Cw, Dh, Dw, D))


# tests
T1 = """
4 4
1 1
4 4
..#.
..#.
.#..
.#..
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
1
"""

T2 = """
4 4
1 4
4 1
.##.
####
####
.##.
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
-1
"""

T3 = """
4 4
2 2
3 3
....
....
....
....
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
0
"""

T4 = """
4 5
1 2
2 5
#.###
####.
#..##
#..##
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
2
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 128836
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>

using namespace std;

typedef long double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  //昇順
  bool operator < (Point p)const{return (p.x!=x)?x<p.x:y<p.y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}
  
  bool contain(Point a){
    return sgn((a-p).norm(),r)<=0;
  }
  
  Circle circumCircle(Point a,Point b){
    Point q=(a+b)/2;
    return Circle(q,(a-q).norm());
  }
  
  Circle circumscribedCircle(Point p, Point q, Point r){
    Point a=(q-p)*2,b=(r-p)*2;
    Point c(p.dot(p)-q.dot(q),p.dot(p)-r.dot(r));
    Circle res;
    res.p.x=a.y*c.y-b.y*c.x;
    res.p.y=b.x*c.x-a.x*c.y;
    res.p=res.p/a.cross(b);
    return Circle(res.p, p.dist(res.p));
  }

  Circle minEnclosingCircle(vector<Point>ps){
    if(ps.size()==0)return Circle(Point(0,0),0);
    if(ps.size()==1)return Circle(ps[0],0);

    Circle circle=circumCircle(ps[0],ps[1]);
    for(int i=2;i<ps.size();i++){
      if(!circle.contain(ps[i])){
	circle=circumCircle(ps[0],ps[i]);
	for(int j=1;j<i;j++){
	  if(!circle.contain(ps[j])){
	    circle=circumCircle(ps[j],ps[i]);
	    for(int k=0;k<j;k++){
	      if(!circle.contain(ps[k])){
		circle=circumscribedCircle(ps[i],ps[j],ps[k]);
	      }
	    }
	  }
	}
      }
    }
    return circle;
  }

};

int main(void){

  int n;
  cin >> n;
  vector<Point>ps(n);

  for(int i=0;i<n;i++)cin >> ps[i].x >> ps[i].y;
  Circle c;
  printf("%.16Lf",c.minEnclosingCircle(ps).r);
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
int dis1[100005]={};
int dis2[100005]={};
int cnt=1;
vector<int>node[100005]={};
void re(int now,int d){
    dis1[now]=d;
    for(int i=0;i<node[now].sz;i++){
        int k=node[now][i];
        if(!dis1[k]){
            re(k,d+1);
        }
    }
}
void re2(int now,int d){
       dis2[now]=d;
    for(int i=0;i<node[now].sz;i++){
        int k=node[now][i];
        if(!dis2[k]){
            re2(k,d+1);
        }
    }
}
int main()
{
    int a;
    while(cin>>a){
        for(int i=0;i<a-1;i++){
            int x,y;
            cin>>x>>y;
            node[x].push_back(y);
            node[y].push_back(x);
        }
        re(1,1);
        re2(a,1);
        int b=0,w=0;
        for(int i=2;i<a;i++){
            if(dis1[i]<=dis2[i])
                b++;
            else
                w++;
        }
        if(b>w){
            cout<<"Fennec"<<endl;
        }
        else{
            cout<<"Snuke"<<endl;
        }






    }


    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int main() {
    int N;
    cin >> N;
    ll ans = 1;
    REP(i,N)
        ans = ans * (i+1) % MOD;
    cout << ans << endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    string s; cin >> s;
    string ans;
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0) ans += s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
package main

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	var n int = nextInt()
	var A []int
	for i := 0; i < n; i++ {
		A = append(A, nextInt())
	}

	//1 selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
	//2   for i が 0 から N-1 まで
	//3     minj = i
	//4     for j が i から N-1 まで
	//5       if A[j] < A[minj]
	//6         minj = j
	//7     A[i] と A[minj] を交換

	var count = 0

	for i := 0; i < n; i++ {
		var minj = i
		for j := i; j < n; j++ {
			if A[j] < A[minj] {
				minj = j
			}
		}
		if A[i] != A[minj] {
			A[i], A[minj] = A[minj], A[i]
			count++
		}

	}
	fprintArray(A)
	fmt.Fprintln(wtr, fmt.Sprint(count))
	_ = wtr.Flush()

}

func fprintArray(arr []int) {
	for i := 0; i < len(arr); i++ {
		if i == 0 {
			fmt.Fprintf(wtr, "%d", arr[i])
		} else {
			fmt.Fprintf(wtr, " %d", arr[i])
		}
	}
	fmt.Fprintln(wtr)
}



Measured memory_bytes: 1140
N = int(input())

List=list(map(int,input().split()))
cnt = 0
for i in range(len(List)):
  if List[i] < 0:
    List[i] = int(-List[i])
    cnt +=1
    
if cnt % 2 == 0:
  print(int(sum(List)))
else:
  a = int(min(List))
  b = int(sum(List))
  print(int(b-a*2))

Measured memory_bytes: 14284
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

int walk(const vector<int>& x, int lim) {
	int cnt = 1;
	int st = x[0];
	FOR(i, 1, x.size()) {
		if (x[i] - st > lim) {
			cnt++;
			st = x[i];
		}
	}
	return cnt;
}


int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> x(M), y;
	REP(i, M)cin >> x[i];
	sort(x.begin(), x.end());

	REP(i, M - 1)y.push_back(x[i + 1] - x[i]);
	sort(y.begin(), y.end(), greater<int>());

	int res = 0;
	REP(i, min(N - 1, M - 1))res += y[i];
	cout << *max_element(x.begin(),x.end()) - *min_element(x.begin(),x.end()) - res << endl;

	return 0;
}


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

int main(void) {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  cout << (s < t ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 764
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

bool contains[100005];
int maxd[100005];
int lvl[100005];
vll adjlist[100005];
int u,v;
int ans;

void dfs(int node,int par){
	lvl[node]=lvl[par]+1;
	maxd[node]=lvl[node];
	if(node==u) contains[node]=1;
	for(int i:adjlist[node]){
		if(i!=par){
			dfs(i,node);
			maxd[node]=max(maxd[i],maxd[node]);
			contains[node]|=contains[i];
		}
	}
	if(contains[node] && lvl[u]-lvl[node]<lvl[node]-lvl[v]){
		int dist=lvl[u]-lvl[v]-2*(lvl[u]-lvl[node]);
		int moves=lvl[u]-lvl[node];
		moves+=maxd[node]-lvl[node];
		moves+=dist/2;
		//cout<<node<<' '<<moves<<endl;
		ans=max(ans,moves);
	}
}

void solve(){  
  	int n;
  	cin>>n>>u>>v;
  	rep(i,0,n-1){
  		int x,y;
  		cin>>x>>y;
  		adjlist[x].pb(y);
  		adjlist[y].pb(x);
  	}
  	ans=(lvl[u]-lvl[v])/2;
  	dfs(v,0);
  	cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 11392
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

cnt = [0] * 10010

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            calc = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if calc <= N:
                cnt[calc] += 1

for i in range(1, N + 1):
    print(cnt[i])

Measured memory_bytes: 9864
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);

//------------------------//
// 0と１が両方存在している -> どこかで0と１が隣り合っている点が存在する
// min (num0, num1)  が答え




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

  int cnt1 = 0, cnt0 = 0;

  REP(i,s.size()){
    if(s[i] == '0') ++cnt0;
    else{ ++cnt1;}
  }

  int ans = 2 * min(cnt0, cnt1);
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

class task {
  public:
    string name;
    int time;
};

int main() {
    int n, q, t = 0;
    cin >> n >> q;
    queue<task> Q;
    task tmp;
    rep(i, n) {
        cin >> tmp.name >> tmp.time;
        Q.push(tmp);
    }

    while(Q.empty() != true) {
        if(Q.front().time <= q) {
            t += Q.front().time;
            cout << Q.front().name << " " << t << endl;
        } else {
            t += q;
            tmp = Q.front();
            tmp.time -= q;
            Q.push(tmp);
        }
        Q.pop();
    }
}



Measured memory_bytes: 6232
num = [int(e) for e in input().split()]

A = num[0]
B = num[1]
C = num[2]

I = B+C         #全部の水の量
L = C-(A-B)     #Cの残りの水の量

if I <= A:
    C = 0
    print(C)
else:
    print(L)

Measured memory_bytes: 3060
while True:
    n = int(input())
    if n == 0:
        break
    ls = []
    for i in range(n):
        v = input().split()
        sum = 0
        for j in range(1,n):
            v[j] = int(v[j])
            if v[j] == 0:
                sum += 100
            if v[j] == 1:
                sum -= 1
        ls.append([sum,-i,v[0]])
    ls = sorted(ls)
    ls.reverse()
    for i in range(n):
        print(ls[i][2])



Measured memory_bytes: 5604
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
 
typedef long long ll;

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
	ll N;
	cin>>N;
	int result = 11;
	REP(i,sqrt(N)+2){
		if(i!=0 && N%i==0){
			int dig = GetDigit(N/i);
			if(dig<result){
				result = dig;
			}
		}
	}
	cout<<result<<endl;
}

Measured memory_bytes: 256
// ProblemURL : https://atcoder.jp/contests/abc090/tasks/abc090_b
// ---------------------------------------------
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ans := 0
	for i := a; i <= b; i++ {
		if i/10000 == i%10 && i/1000%10 == i/10%10 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  std::string s;
  std::cin >> s;
  vector<int> v;
  int left = 0, right = s.size() - 1;
  while (left < right)
  {
    if (s[left] == s[right])
    {
      left++;
      right--;
    }
    else if (s[left] == 'x')
    {
      v.push_back(right);
      left++;
    }
    else if (s[right] == 'x')
    {
      v.push_back(left);
      right--;
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << v.size() << endl;

  return 0;
}


Measured memory_bytes: 1020
//author: Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
      ll k=0;
    cin>>k;
    string s;
    cin>>s;

    ll l=s.length();
    string ans="";
    if(l>k){
        ans+=s.substr(0,k);
        ans+="...";
    }
    else
        ans+=s;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3660
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;

int main()
{
	const ll modP = 1000000007;
	int n;
	cin>>n;
	vector<int> a(n);
	ll sum = 0;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		sum += a[i];
	}
	ll ans = 0;
	for(int i = 0; i < n-1; i++){
		sum = sum - a[i];
		ans += ((a[i]%modP) * (sum % modP)) % modP;
		ans = ans % modP;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3568
# D - Knapsack 1 Educational DP Contest / DP
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N,W = nm()
Weight = []
Value = []

for i in range(N):
    w,v = nm()
    Weight.append(w)
    Value.append(v)

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j >= Weight[i]:
            dp[i+1][j] = max(dp[i][j-Weight[i]]+Value[i],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, k; cin >> n >> k;
	int cnt = 0;
	for (int i = 1; i <= n; i++) if ((2 * i) % k == 0 && i % k != 0) cnt++;
	cout << (long long)cnt * cnt * cnt + (long long)(n / k) * (n / k) * (n / k) << "\n";
	
	return 0;
}


Measured memory_bytes: 3592
#template
def inputlist(): return [int(k) for k in input().split()]
#template
A,B,H,M = inputlist()
from math import pi,cos
def rad_hour(H,M):
    return ((H+(M/60))*pi)/6
def rad_min(M):
    return M*pi/30

rad_h = rad_hour(H,M)
rad_m = rad_min(M)
d_rad = max(rad_h,rad_m) - min(rad_h,rad_m)
theta = min(2*pi-d_rad,d_rad)

l2 = A**2 + B**2 - 2*A*B*cos(theta)
print(l2**(1/2))

Measured memory_bytes: 9540
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n; string s;
    cin>>n>>s;
    vector<int>a(n+1,0);
    int x=0;
    rep(i,n){
        if(s[i]=='W')x++,a[i+1]=x;
        else a[i+1]=x;
    }
    int ans=1e9;
    for(int i=1; i<=n; ++i){
        int w=a[i-1];
        int e=(n-a[n])-(i-a[i]);
        ans=min(ans,w+e);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1796
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string n;
    bool solve=false;
    cin >> n;
    
    for(int i=0;i<n.size();i++){
        if(n[i]=='9') solve=true;
    }
    if(solve) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

/*--------switch header--------*/
#define ALGORITHM   1
#define CASSERT     0
#define CMATH       0
#define DEQUE       0
#define FUNCTIONAL  1
#define IOMANIP     1
#define IOSTREAM    1
#define LIST        0
#define MAP         0
#define QUEUE       0
#define SET         0
#define STRING      1
#define UTILITY     1
#define VECTOR      1
#define VEC_DEBUG   1

using namespace std;

#pragma region headers
#if VEC_DEBUG
#define _GLIBCXX_DEBUG
#endif
#if ALGORITHM
#include <algorithm>
#endif
#if CASSERT
#include <cassert>
#endif
#if CMATH
#include <cmath>
#endif
#if DEQUE
#include <deque>
#endif
#if FUNCTIONAL
#include <functional>
#endif
#if IOMANIP
#include <iomanip>
#endif
#if IOSTREAM
#include <iostream>
#endif
#if LIST
#include <list>
#endif
#if MAP
#include <map>
#endif
#if QUEUE
#include <queue>
#endif
#if SET
#include <set>
#endif
#if STRING
#include <string>
#endif
#if UTILITY
#include <utility>
#endif
#if VECTOR
#include <vector>
#endif
#pragma endregion


/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
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); }

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



/*--------additional--------*/

int gcd(int a, int b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b, a%b);
  }
}

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int k; cin >> k;

    ll ans = 0;
    FOR(a, 1, k+1)
    FOR(b, 1, k+1)
    FOR(c, 1, k+1){
        ans += gcd(gcd(a, b), c);
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3580
#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 n; cin >> n;
    vector<ll> l(n); rep(i,n) cin >> l[i];

    ll ans = 0;
    for(long long i = 0; i < n-2; i++){
        for(long long j = i+1; j < n-1; j++){
            for(long long k = j+1; k < n; k++){
                if(l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j] and l[i] != l[j] and l[i] != l[k] and l[j] != l[k]){
                    ans++;
                    //cout << l[i] << " " << l[j] << " " << l[k] << endl;
                }
            }
        }
    }
    put(ans);
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<tuple>

int n,m;
std::vector<std::vector<int>> edges;
std::vector<int> dist;

int main(){
    std::cin>>n>>m;
    edges.resize(n);
    dist.resize(n, -1);
    for(int i=0; i<m; i++){
        int a,b; std::cin>>a>>b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    std::queue<int> q;
    q.push(0);
    dist[0] = 0;
    while(!q.empty()){
        int src = q.front(); q.pop();
        for(int to:edges[src]){
            if(dist[to] >= 0) continue;
            q.push(to);
            dist[to] = dist[src] + 1;
        }
    }
    if(dist[n-1] == 2) std::puts("POSSIBLE");
    else std:puts("IMPOSSIBLE");

}

Measured memory_bytes: 13168
#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    int ret=0;
    cin >> str;
    int n = str.size();
    for(int i=0;i<n/2;++i){
        if(str[i] == str[n-i-1]){
            if(str[i] == '(' || str[i] == ')'){
                ret++;
            }
        }else{
            if(!((str[i] == '(' && str[n-i-1] == ')') ||
                 (str[i] == ')' && str[n-i-1] == '('))){
                ret++;
            }
        }
    }
    if(n%2==1){
        if(str[n/2] != 'i' && str[n/2] != 'w'){
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 0
"use strict";

const is_palindrome = s => {
    let n = s.length;
    for (let i = 0; i < n; i++) {
        if (s[i] !== s[n - i - 1]) return false;
    }

    return true;
}

const main = (input) => {
    const spi = input.split('\n');
    const s = spi[0];
    const n = s.length;

    if (is_palindrome(s)
        && is_palindrome(s.substring(0, (n-1)/2))
        && is_palindrome(s.substr((n+3)/2-1)))
        console.log("Yes");
    else
        console.log("No");
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29552
#include<stdio.h>
int a[300000],b[300000];
int main(){
	long long n;
	int q,h,w,t;
	scanf("%lld %d",&n,&q);
	h=n;w=n;
	long long ans=(n-2)*(n-2);
	for (int i=1;i<=n;i++){
		a[i]=n;b[i]=n;
	}
	for (int i=1;i<=q;i++){
		int k;
		scanf("%d",&k);
		if (k==1){
			scanf("%d",&t);
			if (t<w){
				for (int j=t;j<w;j++){
				  b[j]=h;
			}
				w=t;
			}
			ans=ans-(b[t]-2);
		}else{
			scanf("%d",&t);
			if (t<h){
				for (int j=t;j<h;j++){
				  a[j]=w;
			}
			    h=t;
			}
			ans=ans-(a[t]-2);	
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int a,b; cin>>a>>b;
	char ans='x';
	if(a+b==15)ans='+';
	if(a*b==15)ans='*';
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3640
n = gets.to_i
s = gets.chomp.chars

left = Hash.new(0)
right = Hash.new(0)
s.each { |c| right[c] += 1 }

ans = 0
cnt = 0
s.each do |c|
  left[c] += 1
  right[c] -= 1
  if left[c] == 1 && right[c] > 0
    cnt += 1
  elsif left[c] > 1 && right[c] == 0 
    cnt -= 1
  end
  ans = cnt if ans < cnt
end
puts ans

Measured memory_bytes: 1788
import numpy as np
N=int(input())
H=np.array(list(map(int, input().split())))
count=0
k=0
for i in range(N-1):
    count+=1
    if H[i]<H[i+1]:
        k=max(k,count-1)
        count=0
print(max(k,count)) 

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 100500;



int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	ll a, b, c;
	cin >> a >> b >> c;
	ll ans = inf;

	if (a >> 1)
		ans = min(ans, b * c * (a & 1));
	if (b >> 1)
		ans = min(ans, a * c * (b & 1));
	if (c >> 1)
		ans = min(ans, a * b * (c & 1));

	cout << ans;
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="SUN")
        cout<<7;
    else if(s=="MON")
        cout<<6;
    else if(s=="TUE")
        cout<<5;
    else if(s=="WED")
        cout<<4;
    else if(s=="THU")
        cout<<3;
    else if(s=="FRI")
        cout<<2;
    else if(s=="SAT")
        cout<<1;
    return 0;
}


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

int main(){
    int a, b;
    
    cin >>a >> b;
    
    int d = a / b;
    int r = a % b;
    double f = double(a) / double(b);
    
    printf("%d %d %f", d, r, f);
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  ll remain=7;
  ll k;
  cin >>k;
  rep(i,3000000){
    remain%=k;
    if(remain==0){cout << i+1 << endl; return 0;}
    remain=remain*10+7;
  }
  cout << -1 << endl;
}

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

int main() {
  int n;
  cin>>n;
  int st[n];
  int ans[n];
  for(int i=0;i<n;i++){
    cin>>st[i];
    ans[st[i]-1]=i+1;
  }
  for(int i=0;i<n;i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    /*
    for(int m = 1; m < 40; m++){
        double e = 0;
        for(int i = 1; i <= m; i++){
            double p = 1;
            for(int j = 0; j < i; j++){
                p *= 1.0 * (m - j) / (40 - j);
            }
            p *= 1.0 * (40 - m) / (40 - i);
            e += p * i;
        }
        printf("m = %d e = %f a - e = %f\n", m, e, m - e);
    }
    */
    int M = 35;
    bool d[40][40] = {};
    for(int i = 0; i < M; i++){
        for(int j = 0; j < M; j++){
            d[i][j] = (i != j);
        }
    }
    for(int i = 0; i < 40; i++){
        for(int j = 0; j < 40; j++){
            if(i != j){
                d[i][j] = !d[i][j];
            }
        }
    }
    cout << 40 << endl;
    REP(i, 40) {
        REP(j, 40) cout << (d[i][j] ? "Y" : "N");
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1112
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
};

typedef vector<set<Edge>> Graph;


signed main(void) {
	int n;
	string s;
	cin >> n >> s;
	int rc = 0, bc = 0;
	REP(i, n) {
		if (s[i] == 'R')
			rc++;
		else
		{
			bc++;
		}
	}

	if (rc > bc)
		cout << "Yes" << endl;
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		System.out.println(ans);
	}

}


Measured memory_bytes: 27984
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class CHalfAndHalf {
public:
  void solve(std::istream &cin, std::ostream &cout) {
    int64_t a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int64_t two_a = min(a, 2 * c);
    int64_t two_b = min(b, 2 * c);
    cout << min({a * x + b * y, 2 * c * max(x, y), 2 * c * min(x, y) + abs(x - y) * (x > y ? a : b)}) << endl;
  }
};


int main() {
  CHalfAndHalf solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(N);
  for (int i = 0; i < 2*M; i++){
    int a;
    cin >> a;
    road.at(a-1) ++;
  }
  for (int i = 0; i < N; i++)
    cout << road.at(i) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long[] A = new long[N];
    for (int i = 0; i < N; i++) A[i] = sc.nextLong();
    sc.close();

    long mod = 1000000007L;
    long[] cmb = new long[N - K + 1];
    cmb[0] = 1;
    for (int i = 1; i <= N - K; i++)
      cmb[i] = modDiv(cmb[i - 1] * (K + i - 1), i, mod);


    long ans = 0;
    Arrays.sort(A);
    for (int i = 0; i < N - K + 1; i++) {
      ans = modAdd(ans, A[N - 1 - i] * cmb[N - K - i], mod);
      ans = modSub(ans, A[i] * cmb[N - K - i], mod);
    }

    System.out.println(ans);
  }

  private static long modAdd(long a, long b, long mod) {
    return ((a % mod) + (b % mod)) % mod;
  }

  private static long modSub(long a, long b, long mod) {
    long ans = ((a % mod) - (b % mod)) % mod;
    return ans < 0 ? ans + mod : ans;
  }

  private static long modDiv(long a, long b, long mod) {
    return (a % mod) * modInv(b, mod) % mod;
  }

  private static long modInv(long x, long mod) {
    return modPow(x, mod - 2, mod);
  }

  private static long modPow(long b, long e, long mod) {
    long ans = 1;
    long x = b % mod;
    for (long y = e; y != 0; y >>= 1) {
      if ((y & 1) == 1) ans = (ans * x) % mod;
      x = (x * x) % mod;
    }
    return ans;
  }
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


LL get(LL x, int t) {
  if (x % t == 0) return x;
  else {
    return ((x / t) + 1) * t;
  }
}

void calc(LL &low, LL &high, int a, int b) {
  if (low / a * b >= high) high = low / a * b;
  else {
    high = get(high, b);
    calc(high, low, b, a);
  }
  return;
}

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

  int t[n];
  int a[n];
  REP (i, n) {
    cin >> t[i] >> a[i];
  }

  LL now_t = 1;
  LL now_a = 1;
  REP (i, n) {
    if (t[i] == a[i]) {
      now_t = max(now_t, now_a);
      now_a = max(now_t, now_a);
    } else if (t[i] < a[i]) {
      now_t = get(now_t, t[i]);
      calc(now_t, now_a, t[i], a[i]);
    } else {
      now_a = get(now_a, a[i]);
      calc(now_a, now_t, a[i], t[i]);
    }
  }

  cout << now_t + now_a << endl;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
        x: [usize;n],
    }

    let mut sum = 0;
    let mut tmp = 0;
    for i in 0..n {
        tmp = x[i];
        if x[i]%2!=0 {
            continue;
        } else {
            while tmp%2==0 {
                sum += 1;
                tmp /= 2;
            }
        }   
    }

    println!("{}", sum);

}


Measured memory_bytes: 2368
#include <stdio.h>

int main(){
	int H,W,i,j;
	while(scanf("%d %d",&H,&W),H>0&&W>0){
		for(i=0;i<H;++i){
			for(j=0;j<W;++j){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
		
	}
	return 0;
}

Measured memory_bytes: 572
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define rpe(i,r,l) for(int i=(r);i>=(l);--i)
#define rpp(i,x,e,head) for(int i=head[x];~i;i=e[i].next)
#define dyes cerr<<"yes"<<endl
#define dbg(x) cerr<<#x<<"="<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pts puts("")
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
inline ll readll(){
    ll f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
template <class T> inline void chmax(T &a,T b){if(a<b) a=b;}
template <class T> inline void chmin(T &a,T b){if(a>b) a=b;}
inline void swap(int &a,int &b){int c=a;a=b;b=c;}
using namespace std;
#define mst(a,val) memset(a,val,sizeof(a))
#define pii pair<int,int>
#define piii pair<int,pair<int,int> >
#define mp(i,j) make_pair(i,j)
#define fi first
#define sc second
#define inf (0x3f3f3f3f)
#define infl (0x3f3f3f3f3f3f3f3fLL)
#define forvec(i,j) for(vector<int>::iterator i=j.begin();i!=j.end();++i)
#define forvecv(i,j) for(vector<int>::iterator i=--j.end();i>=j.begin();--i)
//=====================head end======================//
const int N=1e4+10;
struct node{
    int next,to;
}e[N<<1];
int head[N],cnt;
inline void add(int u,int v){
    e[cnt].to=v;e[cnt].next=head[u];head[u]=cnt++;
}
int n,x[N],y[N],c[N],d[N],vis[N],match[N];
inline bool dfs(int x){
    rpp(i,x,e,head){
        int v=e[i].to;
        if(!vis[v]){
            vis[v]=1;
            if(!match[v]||dfs(match[v])){
                match[v]=x;return 1;
            }
        }
    }
    return 0;
}
int main(){
    mst(head,-1);n=read();rep(i,1,n) x[i]=read(),y[i]=read();
    rep(i,1,n) c[i]=read(),d[i]=read();
    rep(i,1,n)
    rep(j,1,n){
        if(x[i]<c[j]&&y[i]<d[j]){
            add(i,j+n);
        }
    }
    int ans=0;
    rep(i,1,n){
        mst(vis,0);if(dfs(i)) ++ans;
    }
    printf("%d\n",ans);
    return 0;
}









Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];

// 最大積載量Pのk台のトラックで何個の荷物をつめるか？
int check(llong P){
  int i = 0;
  for ( int j = 0; j < k; j++) {
    llong s = 0;
    while( s + T[i] <= P ){
      s += T[i];
      i++;
      if ( i == n ) return n;
    }
  }
  return i;
}

int solve() {
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while ( right - left > 1 ) {
    mid = (left + right) / 2;
    int v = check(mid);
    if ( v >= n ) right = mid;
    else left = mid;
  }
  return right;
}

main() {
  cin >> n >> k;
  for ( int i = 0; i < n; i++ ) cin >> T[i];
  llong ans = solve();
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << max(0, a - 2 * b) << '\n';
    return 0;
}


Measured memory_bytes: 3632
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string a,b;
  cin >> a >> b;
  reverse(all(a));

  if(a == b)
    cout << "YES";
  else
  {
    cout << "NO";
  }
  



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<stdio.h>

int tri(int a,int b,int c){
    int temp;
    if(a!=b && b!=c && c!=a){
        if(a+b>c && b+c>a && c+a>b) temp = 1;
        else temp = 0;
    }else{
        temp = 0;
    }
    return temp;
}

int main(void){
    int n,i,j,k,count=0;

    scanf("%d",&n);

    int l[n];

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

    if(n>=3){
        for(i=0;i<n-2;i++){
            for(j=i+1;j<n-1;j++){
                for(k=j+1;k<n;k++){
                    if(tri(l[i],l[j],l[k])==1){
                        count += 1;
                    }
                }
            }
        }
    }else{
        count = 0;
    }

    printf("%d",count);

    return 0;
}

Measured memory_bytes: 1732
n,*z=`dd`.split.map &:to_i
t=*0...n;e=*t
a=z.shift n+1
n.downto(1){|i|a[i]-=a[i-1]}
k,*z=z
z.map{|x|t[x-2,2]=t[x-1],t[x-2]}
60.times{|i|k[i]>0&&e.map!{|q|t[q]};t=t.map{|q|t[q]}}
k,*a=a
n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 57184
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - 0 or 1 Swap
            int n = int.Parse(Console.ReadLine());
            var p = ReadLine();

            var ascending = p.OrderBy(x => x).ToList();
            int diff = 0;

            for(int i = 0; i < n; i++)
            {
                if (p[i] != ascending[i])
                {
                    diff++;
                }
            }

            if (diff <= 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dp[10][12]; //dp[i][j]代表以i开头的j位数有多少个lun number 
LL k, ans[12]; //ans[i]表示i位lun number的个数
int bit;

void dfs(int num, int alter) { //第一个参数表示第几位(层数), 第二个参数表示变化方式(-1/不变/+1)
	if(num > bit) return ;
	if(num == 1) { //第一位直接枚举1 ~ 9
		for(int i = 1; i <= 9; i++) { //后缀共bit - num + 1位
			if(k > dp[i][bit - num + 1]) k -= dp[i][bit - num + 1];
			else {
				cout << i; //最高位的值
				dfs(num + 1, i); //这时候dfs进入下一层看第二高位是几, 进入else特判内, 记忆化搜索
				break;
			}
		}
	}
	else {
		for(int i = alter - 1; i <= alter + 1; i++) {
			if(!(i >= 0 && i <= 9)) continue;
			if(k > dp[i][bit - num + 1]) k -= dp[i][bit - num + 1];
			else {
				cout << i;
				dfs(num + 1, i);
				break;
			}
		}
	}
}

int main() {
	cin >> k;
	for(int i = 0; i < 10; i++) dp[i][1] = 1;
	ans[1] = 9LL;
	for(int j = 2; j <= 10; j++) { //位数:2 ~ 10
		for(int i = 0; i < 10; i++) { //最高位:0 ~ 9
			if(i == 0) dp[i][j] = dp[i][j - 1] + dp[i + 1][j - 1];
			//最高位i = 0时的j位数只能以i和i + 1作最高位的j - 1位数作为后缀
			else if(i == 9) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
			//最高位i = 9时的j位数只能以i - 1和i作最高位的j - 1位数作为后缀
			else dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1]; 
			//最高位非0非9时, 以i - 1、i本身、i + 1作最高位的j - 1位数均可作为最高位是i的j位数的后缀
			if(i) ans[j] += dp[i][j]; //没有前导0时就将dp[i][j]表示的个数存入ans[j]
		}
	}
	for(int i = 1; i <= 20; i++) {
		if(k > ans[i]) k -= ans[i];
		else {
			bit = i; //所求转化为:位数为bit位的所有数中的第k小的那个(将当前k定位在bit位)
			break;
		}
	}
	dfs(1, 0);
	cout << endl;
	return 0;
}

/*
<-- 数位dp + 构造 -->
设dp[i][j]表示最高位是i, 位数是j的lun number的个数
根据极限样例, j最多为10位, i在0 ~ 9
首先初始化所有dp[i][1] = 1 (以i开头的一位数就是i本身, 只有1个)
转移方程3种情况:
1) dp[i][j] = dp[i][j - 1] + dp[i + 1][j - 1];
//最高位i = 0时的j位数只能以i和i + 1作最高位的j - 1位数作为后缀
2) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
//最高位i = 9时的j位数只能以i - 1和i作最高位的j - 1位数作为后缀
3) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1]; 
//最高位非0非9时, 以i - 1、i本身、i + 1作最高位的j - 1位数均可作为最高位是i的j位数的后缀

接下来进行构造:
首先定位第k小的lun number的位数bit
统计所有i位数中有多少lun number, 做一遍前缀和存进ans[i]
从低位向高位遍历, 找到第一个大于等于k的位数即为k的位数bit

确定好位数之后, 开始枚举每一位是什么
如果是第一位, 我们暴力枚举1 ~ 9
对k执行递减, 看k处于谁开头的bit位数
用找定位位数的方法, 我们可以定位第一个位置的值(已经记录了以i开头, 有j位的lun number有多少个)
然后后面的位置的数只有最多三种选择: 上次减一; 上次同样; 上次加一(在0 ~ 9之间)
然后记忆化搜所即可
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>a>>b>>c>>d;
    	n = (c+b-1)/b;
    	m = (a+d-1)/d;
    	if(n<=m)
    		cout<<"Yes"<<endl;
    	else
    		cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
N = int(input())
W = list(map(int,input().split()))
total = 0
S1 = 0
S2 = 0
ls = []
K = 0
zettaichi = 0
for i in range(N):
    total += W[i]
for j in range(N):
    S1 += W[j]
    S2 = total - S1
    zettaichi = int(abs((S2-S1)))
    ls.append(zettaichi)
    S2 = 0
    zttaichi = 0
    if j == N:
        break
print(min(ls))

Measured memory_bytes: 3064